session.Run(bson.D{{ ..}} not preserving order

33 views
Skip to first unread message

Diego Medina

unread,
Feb 23, 2015, 1:11:57 PM2/23/15
to mgo-...@googlegroups.com
Hi,

using mgo I'm trying to rename a collection, I'm using this:

session.Run(bson.D{{"renameCollection", "test." + tmpNewTradeCollection}, {"to", "new-db." + tmpNewTradeCollection}}, &ret)

and it is failing at random, sometimes it runs ok and when it fails, this is what I get:

map[ok:0 errmsg:no such cmd: to code:59 bad cmd:map[to:acm-web.test_2596996162 renameCollection:test.test_2596996162]]

I'm guessing that it fails because once serialized, it sends the "to" part of the command first, which is incorrect. How am I supposed to solve this?

My setup is a mongo master and slave, the session is set to String with:

session.SetMode(mgo.Strong, true)

so the command should go to the master server.

Thanks and let me know if you need any more information

Diego

Gustavo Niemeyer

unread,
Feb 23, 2015, 1:20:09 PM2/23/15
to mgo-...@googlegroups.com
Hi Diego,

bson.D sends document fields in the exact same order in which they
were provided, so that cannot be the cause of the failure.

If you have a small self-contained snippet demonstrating the issue you
have, I'm happy to have a look at it.
> --
> You received this message because you are subscribed to the Google Groups
> "mgo-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mgo-users+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--

gustavo @ http://niemeyer.net

Diego Medina

unread,
Feb 23, 2015, 1:24:38 PM2/23/15
to mgo-...@googlegroups.com
Hi Gustavo,

Thanks for the quick reply, so some reason I cannot replicate this on my local setup, it only happens on our production servers. And even there, today I run this task three times and one of them worked ok. I'll try to narrow it down more.

Thanks




--
You received this message because you are subscribed to a topic in the Google Groups "mgo-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mgo-users/Gcf_srT1vVU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mgo-users+...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Diego Medina
Lift/Scala consultant
di...@fmpwizard.com
http://fmpwizard.telegr.am

Diego Medina

unread,
Feb 23, 2015, 1:49:32 PM2/23/15
to mgo-...@googlegroups.com, di...@fmpwizard.com
I think the last time it failed was related to me deploying the wring binary, when was it first failing , I was using a bson.M, I then went to bson.D .

So far I run the process twice more and both times it worked ok.

Thanks

Gustavo Niemeyer

unread,
Feb 23, 2015, 1:50:50 PM2/23/15
to mgo-...@googlegroups.com, di...@fmpwizard.com
Okay, bson.M indeed has no defined ordering.
Reply all
Reply to author
Forward
0 new messages