rethinkdb / rethinkdb-python

Python driver for RethinkDB
https://rethinkdb.com/api/python/
Apache License 2.0
64 stars 35 forks source link

Python Error: %d format: a number is required, not str #206

Open fkollmann opened 8 years ago

fkollmann commented 8 years ago

rethinkdb export does not work!

It causes the python driver to crash: ReQL error during 'version check': Could not connect to localhost:28015. Error: %d format: a number is required, not str

the driver seems to be up-to-date:

sudo pip show rethinkdb

---
Name: rethinkdb
Version: 2.3.0
Location: /usr/lib/python2.7/site-packages
Requires:

Running command:

/usr/bin/rethinkdb dump --password '*******' --temp-dir $TEMPDIR --file "$BACKUPDIR/rethinkdb_dump_$(date +'%Y%m%d_%H%M%S').tar.gz"
adamsvoboda commented 8 years ago

@fkollmann , issue rethinkdb/rethinkdb#5624 discusses the same error. It was caused by providing an invalid password. Not a very informational error message, but sounds like it'll be fixed in the next version.

fkollmann commented 8 years ago

The password is correct. I just changed it:

r.db('rethinkdb').table('users').get('admin').update({ password: '*****' })
nighelles commented 8 years ago

Hey @fkollmann , the --password option should interactively allow you to input the password, rather than typing the password as an argument to the option. Is this the behavior that you're seeing on your end?

fkollmann commented 8 years ago

Okay, I found the issue. I use the following command to do the backup:

/usr/bin/rethinkdb dump --password-file /etc/rethinkdb-admin-pwd --temp-dir $TEMPDIR --file "$BACKUPDIR/rethinkdb_dump_$(date +'%Y%m%d_%H%M%S').tar.gz"

This command works, if issued from the shell. But it always fails, if running inside a script.

fkollmann commented 8 years ago

From shell:

exg-retdb001:~ # /usr/bin/rethinkdb dump --password-file /etc/rethinkdb-admin-pwd --temp-dir $TEMPDIR --file "$BACKUPDIR/rethinkdb_dump_$(date +'%Y%m%d_%H%M%S').tar.gz"
NOTE: 'rethinkdb-dump' saves data and secondary indexes, but does *not* save
 cluster metadata.  You will need to recreate your cluster setup yourself after
 you run 'rethinkdb-restore'.
Exporting to directory...
[========================================] 100%
10269 rows exported from 20 tables, with 50 secondary indexes
  Done (3 seconds)
Zipping export directory...
  Done (0 seconds)

from script:

exg-retdb001:~ # backup-rethinkdb.sh
NOTE: 'rethinkdb-dump' saves data and secondary indexes, but does *not* save
 cluster metadata.  You will need to recreate your cluster setup yourself after
 you run 'rethinkdb-restore'.
Exporting to directory...
ReQL error during 'version check': Could not connect to localhost:28015. Error: %d format: a number is required, not str
Error: rethinkdb-export failed
danielmewes commented 8 years ago

Thanks for your research @fkollmann . Sounds like we might have an issue with non-interactive sessions even when the --password-file option is used instead of --password. We'll look into it.

danielmewes commented 8 years ago

@fkollmann I actually can't reproduce this so far. Are you able to share the full backup-rethinkdb.sh script? You can also email it to me: daniel@rethinkdb.com

fkollmann commented 8 years ago

The full backups script:

#!/bin/bash
set -e

BACKUPDIR=/mnt/resource/db_backups
TEMPDIR=/mnt/resource/db_backups_tmp

mkdir -p $BACKUPDIR
mkdir -p $TEMPDIR

# create dump
/usr/bin/rethinkdb dump --password-file /etc/rethinkdb-admin-pwd --temp-dir $TEMPDIR --file "$BACKUPDIR/rethinkdb_dump_$(date +'%Y%m%d_%H%M%S').tar.gz"

# on success, delete old backups
/usr/bin/find $BACKUPDIR -maxdepth 1 -name 'rethinkdb_dump_*' -ctime '+2' -delete

# upload backup
/usr/bin/mozyutil start

I tested the script running in a sudo shell (sudo -i) on SLES 12 server.

danielmewes commented 8 years ago

@fkollmann Thanks for sharing your script. It still appears to be working for me. What is the Python version that comes with SLES 12? (python --version)

fkollmann commented 8 years ago
exg-retdb001:~ # python --version
Python 2.7.9

exg-retdb001:~ # bash --version
GNU bash, version 4.2.47(1)-release (x86_64-suse-linux-gnu)
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.