Bug 866385 - Can not restore data in mongodb successfully
Can not restore data in mongodb successfully
Status: CLOSED CURRENTRELEASE
Product: OpenShift Origin
Classification: Red Hat
Component: Containers (Show other bugs)
2.x
Unspecified Unspecified
medium Severity medium
: ---
: ---
Assigned To: Ram Ranganathan
libra bugs
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-10-15 05:09 EDT by Rony Gong
Modified: 2015-05-14 19:00 EDT (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-11-06 13:49:59 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Rony Gong 2012-10-15 05:09:42 EDT
Description of problem:
mongdb data couldn't be restored back successfully,  this happened for all app type(scalable and non_scalable)

Version-Release number of selected component (if applicable):
devenv_2327
client(0.99.5)build from devenv_2327

How reproducible:
always

Steps to Reproduce:
1.Create an app and embed mongodb
2.Ssh into this app and make some data into this mogodb
$mongo
$use $yourappname
show dbs
show collections
db.createCollection(“user”)
doc = { author : 'joe', created : new Date('05/29/2012') }
db.user.insert(doc)
db.user.find()
3.Snapshot save this app in CLI
$ rhc snapshot save -a qphp
4.Ssh into this app again and remove the data in mongodb created in step2
$$mongo
$use $yourappname
show dbs
show collections
db.user.remove({"author" : "joe"})
db.user.find()
5.Snapshot restore this app in CLI
$ rhc snapshot restore-a qphp
6.Check the data in mongodb restore back.
  
Actual results:[openshift@F17x64-openshift open-rhc]$ rhc snapshot restore qphp
Password: 

Restoring from snapshot qphp.tar.gz...
restart_on_add=false
Waiting for stop to finish
Done
Removing old git repo: ~/git/qphp.git/
Removing old data dir: ~/app-root/data/*
Restoring ~/git/qphp.git and ~/app-root/data
Running extra restore for mongodb-2.2
connected to: 127.0.251.129:27017
1 objects found
connected to: 127.0.251.129:27017
1 objects found
assertion: 13111 field not found, expected type 2
restart_on_add=false
~/git/qphp.git ~
~
Running .openshift/action_hooks/pre_build
Running .openshift/action_hooks/build
MongoDB already running
Running .openshift/action_hooks/deploy
hot_deploy_added=false
MongoDB already running
Done
Running .openshift/action_hooks/post_deploy


db.user.find() show blank

RESULT:
Success


Expected results:
The data in mongodb restore back, same as step2
> db.user.find()
{ "_id" : ObjectId("507bcac93578633fa1e3d498"), "author" : "joe", "created" : ISODate("2012-05-29T04:00:00Z") }

Additional info:
Comment 1 Dan Mace 2012-10-15 17:18:46 EDT
Couldn't reproduce the problem in devenv_2329. The user is successfully restored when following the same steps listed, with a php-5.3 app.
Comment 2 Ram Ranganathan 2012-10-15 19:25:53 EDT
Fixed with pull request: 
    https://github.com/openshift/origin-server/pull/680

Waiting on merge.


Please note that your test case above has an issue that you may hit : 
    https://jira.mongodb.org/browse/SERVER-7104

this is a mongo bug in 2.2 and to workaround this, don't use db.createCollection('user') in mongo shell (mongo). 
Instead use: db.user.save(doc);  -- that works.
Comment 3 Rony Gong 2012-10-17 01:41:03 EDT
Verified on devenv_2340
after restore, the data in mongodb restore back:
[qsruby18-qgong7.dev.rhcloud.com ~]\> mongo
MongoDB shell version: 2.2.0
connecting to: e4c7fa7ee6-qgong7.dev.rhcloud.com:35586/admin
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
	http://docs.mongodb.org/
Questions? Try the support group
	http://groups.google.com/group/mongodb-user
> use qsruby18
switched to db qsruby18
> db.user.find()
{ "_id" : ObjectId("507e41fb8b34da763fcab75e"), "author" : "joe", "created" : ISODate("2012-05-29T04:00:00Z") }
Comment 4 Wei Sun 2012-10-19 04:39:40 EDT
Re-open this bug,because it is reproduced on devenv_2348,rhc client is rhc-0.99.9
Comment 5 Ram Ranganathan 2012-10-19 14:33:00 EDT
This works fine for me on devenv 2352.  Are you using  db.createCollection() in 
mongoshell??  Don't use that as mongo shell (/usr/bin/mongo) messes up the metadata.   See comment #2.

Don't use db.createCollection('user') in mongo shell (mongo). 
Instead use: db.user.save(doc);  -- that works.
Comment 6 Rony Gong 2012-10-22 00:33:53 EDT
Verified on devenv_2360
Steps:
1.Create app and embed mongodb
2.Preparde data
> use qnodejs
switched to db qnodejs
> doc = { author : 'joe', created : new Date('05/29/2012') }
{ "author" : "joe", "created" : ISODate("2012-05-29T04:00:00Z") }
> db.user.save(doc)
> db.user.find()
{ "_id" : ObjectId("5084bd94f620111fcfeae853"), "author" : "joe", "created" : ISODate("2012-05-29T04:00:00Z") }
> exit
bye
3.snapshot save, then update the mongodb data
4.snapshot restore and check the mongodb data
> use qnodejs
switched to db qnodejs
> db.user.find()
{ "_id" : ObjectId("5084bd94f620111fcfeae853"), "author" : "joe", "created" : ISODate("2012-05-29T04:00:00Z") }

Note You need to log in before you can comment on or make changes to this bug.