inserting wrong collection

133 views
Skip to first unread message

tanaydin sirin

unread,
Jun 21, 2012, 11:07:21 AM6/21/12
to mongod...@googlegroups.com
hi there...

i have a code that insert a document to a collection...
collection name is hardcoded, sending safe=True... but sometimes it inserts to another random collection...

do anyone have similar issue ?

मैं एक भारतीय बेवकूफ हूँ

unread,
Jun 21, 2012, 11:12:55 AM6/21/12
to mongod...@googlegroups.com


tanaydin sirin wrote:
> hi there...
>
> i have a code that insert a document to a collection...
> collection name is hardcoded, sending safe=True... but sometimes it
> inserts to another random collection...
>
You're saying that MongoDB inserts your data into random collections?
Where is your code? And how can someone reproduce that?

tanaydin sirin

unread,
Jun 21, 2012, 11:33:44 AM6/21/12
to mongod...@googlegroups.com
it generally inserts into right collection... but there is some several documents that inserted into another collections... 
we are coded this code with python, i don't know how to reproduce cause it happens randomly...

मैं एक भारतीय बेवकूफ हूँ

unread,
Jun 21, 2012, 11:44:37 AM6/21/12
to mongod...@googlegroups.com
Likely your application is your problem, brother
> --
> You received this message because you are subscribed to the Google
> Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com
> To unsubscribe from this group, send email to
> mongodb-user...@googlegroups.com
> See also the IRC channel -- freenode.net#mongodb

markh

unread,
Jun 21, 2012, 12:03:04 PM6/21/12
to mongod...@googlegroups.com
Hi,

Can you reproduce this in the mongo shell?

Can you share a (sanitised) snippet of your code?

Thanks, Mark


On Thursday, June 21, 2012 4:44:37 PM UTC+1, मैं एक भारतीय बेवकूफ हूँ wrote:
Likely your application is your problem, brother


tanaydin sirin wrote:
> it generally inserts into right collection... but there is some several
> documents that inserted into another collections...
> we are coded this code with python, i don't know how to reproduce cause
> it happens randomly...
>
> --
> You received this message because you are subscribed to the Google
> Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com
> To unsubscribe from this group, send email to

tanaydin sirin

unread,
Jun 21, 2012, 7:25:46 PM6/21/12
to mongod...@googlegroups.com
hi there... here is my code... sorry but i can't reproduce it... only thing i can say about this, there is like 30-50 inserts per second...

ReportRow = {
        "sID" : ID,
        "oID" : "f" + str(strftime("%Y%m%d%H%M%S", 
        "type" : tempData["type"],
        "date" : str(datetime.datetime.utcnow()),
        "send" : 0,
        "assigned" : int(strftime("%S", gmtime())) % 12
}
self.mongoins.insert("report", ReportRow)


and here is the insert function

def insert(self , collName , data):
        self.collection = self.Dbase[collName]
        if type(data) is UnicodeType:
            data = json.loads(data)
        retData = {}
        try:
            retData['_id'] = self.collection.insert(data, safe=True)
        except pymongo.errors.OperationFailure:
            retData['error'] = str(sys.exc_info()[1])
        self.conn.end_request()
        return retData

tanaydin sirin

unread,
Jun 21, 2012, 7:27:37 PM6/21/12
to mongod...@googlegroups.com
it generally (%99) inserts into report collection... but i can find ReportRow in other collections...

Ross Lawley

unread,
Jun 22, 2012, 2:51:32 PM6/22/12
to mongod...@googlegroups.com
The posted code looks fine - can you post the self.Dbase[collName] - logic - is that a class or abstraction on top of a pymongo connection?

Also to confirm, there are no other processes / code that inserts into ReportRow data (not via the shell or anything).

I suspect there is a coding issue, with the abstraction being used above the driver.

tanaydin sirin

unread,
Jun 22, 2012, 3:36:51 PM6/22/12
to mongod...@googlegroups.com
here is my mongo class init function contents...

                cfg["mongoIpAddress"] = "127.0.0.1"
                cfg["mongoPort"] = "27017"
                cfg["mongoDbName"] = "xxxx"
                cfg["mongoDbUser"] = "xxxxx"
                cfg["mongoDbPass"] = "xxxxxx"
                
                self.conn = Connection("mongodb://" + cfg["mongoDbUser"] + ":" + cfg["mongoDbPass"] + "@" + cfg["mongoIpAddress"] + ":" + cfg["mongoPort"] + "/" + cfg["mongoDbName"] + "?socketTimeoutMS=3000")
                self.Dbase = self.conn[cfg["mongoDbName"]]

it's interesting point that we are using same functions and instance all of our project, but only this ReportRow stuff have problem like this... everything works great except that and it is not failing all the time...

there is other processes that inserts to report... we have a multi server, multitask project and it inserts data continuously...

Ross Lawley

unread,
Jun 25, 2012, 6:06:58 AM6/25/12
to mongod...@googlegroups.com
Hi,

Just to confirm you only have one cfg object across your projects and that nothing else can set / overwrite cfg or self.Dbase.   Whats your stack for running this?   mod_wsgi?  Apache or nginx?

Ross

tanaydin sirin

unread,
Jun 25, 2012, 7:11:23 AM6/25/12
to mongod...@googlegroups.com
hi,

we coded config in our module so it is hardcoded (don't ask why :) ) so it is not changing... we are running our project as separate processes, the code i shared is our api side so it listens as jsonrpc server and passes data to mongodb. it is so interesting that, only this document goes wrong sometimes, other documents and functions that use same instance and insert code works without any problem...

i know that kind of issue is so weird and we can't reproduce so there is no clue why this happens, but i don't know what can i do...

we are using debian 6.0.5 on with 2.6.32-5-amd64 kernel, mongo 2.0.6... installed by apt-get...

tanaydin sirin

unread,
Jun 26, 2012, 4:00:01 AM6/26/12
to mongod...@googlegroups.com
and also let me tell you that, our report collection has 169.509.502 documents right now... i don't know this is a clue or not i just want to give more information...

markh

unread,
Jun 27, 2012, 8:29:34 AM6/27/12
to mongod...@googlegroups.com
Hi,

There's not much we can do here as the issue can't be reproduced and no one-else has experienced such an issue.

If you reproduce it, let us know and we'll look into it.

tanaydin sirin

unread,
Jun 27, 2012, 9:44:55 AM6/27/12
to mongod...@googlegroups.com
ok, i'll work on this and if i can get any clue or solution i'll post here again... and also if there is an error with my application i'll post here too to inform everybody...

thanks all for help and information.

Asya Kamsky

unread,
Mar 16, 2013, 7:25:09 PM3/16/13
to mongod...@googlegroups.com
Maybe it would help if you let us know exactly what the issue is.
What other collection is data being inserted into?  Is it data that _should_ have been inserted into the correct collection?  Is it random data or correct document?
What version of mongoDB are you using?  What version of the driver?  What else is accessing the database and how?

I wouldn't expect there is any "news" because no one had a reproducible case - we don't have any way of knowing if it was someone doing something manually, bug in application, bug in driver, incorrect usage, etc.

Asya

On Friday, March 15, 2013 1:55:32 AM UTC-7, yann degat wrote:
any news on this issue ? 

we are encountering the same issue within a grails app, gmongo over java mnogo driver. 

tanaydin sirin

unread,
Jul 17, 2013, 7:25:21 AM7/17/13
to mongod...@googlegroups.com
hi there

we noticed that, it writes to wrong collection that have custom _id value. maybe that could help a bit.

tanaydin sirin

unread,
Sep 23, 2013, 9:41:36 AM9/23/13
to mongod...@googlegroups.com
we found out that, our code has a problem that causes this wrong behaviour... sorry for false alarm...
Reply all
Reply to author
Forward
0 new messages