PMXBOT Log file Viewer

Help | Karma | Search:

#mongodb logs for Wednesday the 9th of October, 2013

(Back to #mongodb overview) (Back to channel listing) (Animate logs)
[00:05:49] <talbott> hi guys
[00:06:14] <talbott> so, i've got what i wanted to be a primary
[00:06:25] <talbott> and was trying to add a secondary
[00:06:39] <talbott> but in the process, i hadnt got the auth setup correctly
[00:06:43] <talbott> i have now fixed this
[00:06:49] <talbott> and have set up 2 x secondaries
[00:07:02] <talbott> but now when i go to the primary to try to add the other secondary
[00:07:07] <talbott> it thinks the primary is a secondary
[00:07:15] <talbott> not quite sure where to go from there...
[00:09:09] <talbott> is there a way to restart the initiate?
[00:53:04] <talbott> i did an rs.remove
[00:53:10] <talbott> and then an rs.add
[00:53:27] <talbott> but i always get: "lastHeartbeatMessage" : "still initializing"
[01:27:53] <dllama> anyone around?
[01:28:20] <dllama> i turned off mongod hoping to enable text search, but now i can't get it to turn back on with the db
[01:32:34] <cheeser> waht's the error?
[01:32:52] <dllama> ERROR: child process failed, exited with error number 100
[01:33:14] <dllama> i just started it up with —dbpath /var/lib/mongod
[01:33:28] <dllama> i have 6gb of data in that folder, but when i login via mongo console, it shows the db as empty
[01:34:40] <dllama> ok this is weird, now it reloaded the data
[01:34:49] <cheeser> i have the magic touch
[01:35:45] <dllama> lol
[01:35:54] <dllama> no idea what i did
[01:35:56] <crudson> make sure you back up before enabling text search, as suggested in the docs
[01:36:01] <dllama> but i kept turning it off and back
[01:36:08] <dllama> oh? anyone got a link please?
[01:36:41] <crudson> http://docs.mongodb.org/manual/core/text-search/ http://docs.mongodb.org/manual/tutorial/enable-text-search/
[01:36:58] <crudson> usually big red boxes should be taken seriously :)
[01:37:05] <dllama> hmm, not to be used in production?
[01:37:18] <crudson> you have to specify it every time you run
[01:37:19] <cheeser> it's experimental in 2.4
[01:37:28] <dllama> there goes that idea… guess i gotta setup solr :/
[01:39:05] <cheeser> or wait for 2.6
[01:41:52] <ruphos> is there a page somewhere listing messages that go with the various error codes? I was having trouble finding one earlier and digging through source every time is quite the bother
[01:44:35] <cheeser> just the source, sadly
[01:45:05] <ruphos> phooey.
[05:43:54] <jhonkola> hello
[05:45:16] <jhonkola> I'm getting ConnectionFailure with "ids don't match" when trying to connect to mongo
[05:45:41] <jhonkola> with pymongo 2.6.2, mongodb 2.4.5
[05:46:17] <jhonkola> connection is being made from django 1.4.5 running on gunicorn (4 workers) and nginx
[05:47:18] <jhonkola> Issue PYTHON-398 on JIRA claims that a similar error is fixed on pymongo 2.1.1
[05:47:39] <jhonkola> ?
[06:08:31] <das3in> Hi, I'm trying to learn mongodb after a long time with SQL, I'm having trouble finding how query for specific fields. I want to set a variable (say var a = ) "Select ID From Users"
[06:09:02] <das3in> and I know I can do like, db.Users.find({name: "whatever"}) but I just want the id not everything
[06:10:48] <pplcf> http://docs.mongodb.org/manual/reference/method/db.collection.find/#projections
[06:13:43] <jhonkola> try db.Users.find({name:"whatever"},{_id:true})
[06:14:20] <jhonkola> mongo has a special _id field, just put the name of field(s) in the latter {}
[06:14:41] <das3in> jhonkola: nailed it! thanks!
[06:21:07] <das3in> Ok now second question
[06:21:37] <das3in> I want to query another collection with the result of that query
[06:24:09] <liquid-silence> what would be the best way to do this, I have a top level document and need to add a collection of documents into it, called files
[06:24:25] <liquid-silence> so file: [ {name: "test" }, {name: "test"
[06:24:35] <liquid-silence> basicaly an array of sub documents
[06:32:14] <mark____> http://pastebin.com/Fw0vurdd
[06:39:10] <mark____> i think u miss my question
[06:42:44] <pplcf> "db" variable is out of scope
[06:43:04] <pplcf> " console.log(err);} "
[06:47:21] <__sri> is there any documentation for the upcoming insert/update/delete commands yet?
[07:25:25] <liquid-silence> hmmm I am trying to get to grips with this data structure
[07:28:45] <liquid-silence> anyone care to give me a hand?
[07:38:20] <liquid-silence> anyone around?
[07:51:09] <liquid-silence> how does one return only the element in question
[07:51:26] <liquid-silence> currently db.containers.find({"folders.name" : "another test folder"}) returns the whole document
[07:51:36] <liquid-silence> I only want the "assets" in the folder
[07:52:34] <ron> db.contains.find({query}, {"assets":true}) iirc. been a while.
[07:53:20] <liquid-silence> hmm that retusn the object id
[07:54:04] <liquid-silence> {
[07:54:04] <liquid-silence> "_id": ObjectId("5255089a55e3382ed99b23a1")
[07:54:04] <liquid-silence> }
[07:54:07] <liquid-silence> makes no sense :P
[07:54:24] <ron> can you show a sample document?
[07:54:28] <ron> and don't paste it here
[07:54:53] <liquid-silence> haha
[07:55:03] <liquid-silence> http://pastie.org/8388711
[07:55:11] <liquid-silence> I dont know if my structure is 100% correct
[07:55:30] <liquid-silence> assets might also be on the root document aswell
[07:55:47] <liquid-silence> current query is db.containers.find({"folders.name" : "another test folder"}, { "assets": true})
[07:56:26] <ron> yes, but assests is not at the root. try changing to folders.assets.
[07:59:28] <liquid-silence> hmm that looks weird
[08:00:07] <liquid-silence> http://pastie.org/8388717
[08:00:13] <liquid-silence> it still has all the other white noise
[08:02:22] <liquid-silence> I presume that is how it is going to be?
[08:02:49] <ron> what other noise? it's got what you want.
[08:03:08] <liquid-silence> it still has folders { },
[08:03:47] <liquid-silence> and the object id
[08:03:50] <liquid-silence> etc..
[08:03:54] <liquid-silence> why does that need to be there
[08:04:11] <ron> it gives you the structure you use, yes. the object id comes by default. you have to remove it if you want (that is, "_id":false)
[08:04:12] <liquid-silence> what if I just wanted that current folder node and all the sub nodes
[08:04:53] <liquid-silence> if I wanted this
[08:04:54] <liquid-silence> http://pastie.org/8388723
[08:05:14] <ron> okay, so ask for that.
[08:05:28] <ron> I'm not sure how to remove the empty array nodes, not sure if you can.
[08:06:13] <HashMap> you probably need to use the aggregation fw
[08:06:34] <liquid-silence> ok so if I just want what I have pasted in pastie
[08:06:37] <liquid-silence> how would I go about it
[08:07:55] <ron> liquid-silence: either what HashMap suggested or use a different document structure. you can't have it all, man.
[08:09:09] <liquid-silence> how should my structure differ?
[08:09:19] <liquid-silence> sorry coming from SQL :(
[08:10:15] <ron> no worries, it's a fair question. but that question can't be answered without knowing more details. like what kind of queries you want to do, how do you normally update your data and so on.
[08:11:19] <liquid-silence> well I would like to query the container, and get all the folders, assets that are part of the root
[08:11:36] <liquid-silence> then the user will navigate into a folder, and he will have subfolders and assets
[08:11:56] <liquid-silence> its a directory structure
[08:11:56] <ron> you're trying to create a tree structure?
[08:12:03] <liquid-silence> where the container is the root
[08:12:09] <ron> same thing
[08:12:15] <liquid-silence> in essence a tree structure yes
[08:12:46] <ron> well, if you intend on reading it as a whole, then store it all in one document. if you intend on reading it one directory at a time, you'd probably want to flatten the structure.
[08:12:53] <ron> having one entry per directory.
[08:14:01] <liquid-silence> a collections for directories, assets, folders?
[08:14:29] <ron> again, I don't know your reading pattern.
[08:14:38] <liquid-silence> well
[08:14:51] <liquid-silence> like you would transverse a directory strucutre
[08:15:09] <liquid-silence> simaler to cd….. ls etc...
[08:15:56] <liquid-silence> so I was thinking one document with nested documents would be fine
[08:16:21] <liquid-silence> looking at this
[08:16:22] <liquid-silence> http://docs.mongodb.org/manual/tutorial/model-tree-structures-with-ancestors-array/
[08:16:57] <HashMap> wouldn't it be better to have a document for a folder/file and an array of subfolder id's?
[08:17:36] <liquid-silence> well coming from SQL I have no idea
[08:18:19] <liquid-silence> so parent child relationship
[08:18:34] <liquid-silence> in essence, but why have arrays then
[08:19:07] <HashMap> i think it's for ease of use.. you can get an array of subfolders on one find
[08:30:04] <talbott> hello mongo-ers
[08:45:47] <talbott_> i have removed and added my secondaries from the rs.conf
[08:46:23] <talbott_> and i can get to each of them from the command line mongo interface
[08:46:46] <talbott_> but when i add them, rs.status() says "lastHeartbeatMessage" : "still initializing" forever
[08:48:44] <talbott_> any ideas?
[09:33:06] <Veejay> Hello everyone, what exactly is a mongo session? And is there a limit to the number of Mongo open sessions?
[09:37:09] <maasan> i uses mongoose with mongodb. If mongo db stops, server throws exceptions and stops accepting post request. How and where to handle mongodb connect issue?
[09:56:41] <remonvv> Veejay: No such thing.
[09:58:04] <remonvv> Veejay: The two concepts somewhat related to sessions areconnections which are a limited resource and live for as long as the connection is open, and cursors.
[10:12:08] <Veejay> remonvv: To be more precise I'm using Mongoid which has Mongoid::Sessions thus my asking. But I guess Mongoid is another topic that falls out of the scope of this channel. So thanks :)
[10:13:30] <remonvv> Well, mappers and drivers are valid topics, but I can't help you with that ;) Mongo doesn't have sessions though.
[10:21:23] <BlackPanx> can i ask is there a way to change REST interface port ?
[11:04:25] <maasan> what is auto_reconnect in mongoose?
[11:04:48] <ron> oh, I guess it... automatically reconnects on connection loss.
[11:04:51] <Zelest> isn't that pretty self-explaining? :P
[11:04:55] <ron> but that's like.. throwing it out there.
[11:06:01] <maasan> does it try to reconnect for every specific time perioed? does it happen on next mongo db request?
[11:11:52] <bmcgee> hey guys, I have a really simple tailable cursor in Java which seems to just refuse to work. I'm running 2.4.5, with collection.find().addOption(Bytes.QUERYOPTION_TAILABLE)
[11:12:14] <bmcgee> I'm periodically check if the cursor hasNext(), but it never does despite there being new entries in the capped collection
[11:12:24] <bmcgee> I've verified the collection is capped also
[12:25:22] <Neptu> hej have a question, I just tested the tutorial and created a replica set with a master and 3 replicas
[12:25:37] <Neptu> I tried to add 4 arbiters but only accepts 3
[12:25:50] <Neptu> i can only have one arbiter per replica?
[12:26:20] <supermang> Neptu can you send me the link for that? Im trying to setup a 3 cluster sharded environment also
[12:26:51] <supermang> I cant find a good tutorial that explains the process well.
[12:27:12] <joannac> Why do you need 4 arbiters?!
[12:29:20] <Neptu> supermang, Im not sharding this is jusst a replica set... trying to play with it to understand it
[12:29:25] <joannac> supermang: You don't like the tutorial in the docs? http://docs.mongodb.org/manual/tutorial/deploy-shard-cluster/
[12:29:48] <Neptu> joannac, just playing aroudn and learning... but its curious you can not get as many arbiters as you want
[12:29:55] <joannac> Neptu: there is absolutely no benefit to having more arbiters
[12:30:26] <supermang> joannac it dosent explain enough for me.
[12:30:41] <Neptu> joannac,I mean if they only help you to vote the maximum should be the same as nodes you have in your replica
[12:30:52] <Neptu> not the amount of replica servers
[12:30:54] <supermang> Maybe im to much of a mongo newb.
[12:31:18] <Neptu> supermang, so far its been extremely easy by far compared with other databases
[12:31:23] <Neptu> mongo is dam easy
[12:31:28] <joannac> Neptu: what?
[12:31:36] <Neptu> setup a replica set
[12:31:57] <Neptu> took longer to have 4 virtual machines than setup the configuration
[12:32:13] <supermang> this is the first time im using nosql database.
[12:32:38] <Neptu> joannac, a question now that I configured on the console the replica set if I turn all off and turn it on the configuration is still available?
[12:32:46] <joannac> Neptu: How does haveing a primary, 3 secondaries, and 4 arbiters help?
[12:32:47] <Neptu> supermang, me too
[12:32:58] <joannac> vs 1 primary, 3 secondaries, and 1 arbiter?
[12:33:54] <Neptu> joannac, I setup for ubuntu machines with one mongo each. I created a replica set of 4 mongod and I created 4 arbiter mongod processes aswell
[12:34:02] <Neptu> when I add arbiters to the replica set
[12:34:08] <Neptu> only accept 3
[12:34:10] <Neptu> not 4
[12:34:13] <joannac> Neptu: Yes, but WHY
[12:34:22] <joannac> WHY do you need 4 arbiters?
[12:34:28] <Neptu> joannac, no Idea, just hope someone knows.
[12:34:32] <Neptu> joannac, playing around
[12:34:49] <joannac> Neptu: okay, so my response is, you would never need more than one arboter.
[12:35:42] <joannac> supermang: sign up for one of the courses, if you need a walkthrough on sharding?
[12:36:05] <joannac> M102 definitely walks through, i think the M101X courses do too but not 100% on that
[12:36:51] <supermang> I will check it out.
[12:38:55] <Nomikos> new to mongodb, long-winded question.. http://stackoverflow.com/questions/19272209/mongodb-category-tallies-of-found-set
[12:39:11] <Neptu> M102 is running second week now, Im running it quite easy so far aswell
[12:39:30] <joannac> Nomikos: DO I know you from another network?
[12:39:39] <Neptu> could be cool to have all the weeks from the begining
[12:39:47] <Neptu> so you can go over all in one day or so
[12:39:48] <Nomikos> joannac: I suspect you do.
[12:40:00] <Neptu> here is like slow slow 7 weeks
[12:40:20] <Neptu> my friend just got the 4 certifications...
[12:41:44] <Neptu> java, python, jnode, dba
[12:41:47] <joannac> Nomikos: aggregation
[12:42:34] <joannac> $group with {$sum: 1}
[12:43:12] <jhonkola_> I'm getting ConnectionFailure with "ids don't match" when trying to connect to mongo
[12:43:20] <jhonkola_> with pymongo 2.6.2, mongodb 2.4.5
[12:43:28] <jhonkola_> connection is being made from django 1.4.5 running on gunicorn (4 workers) and nginx
[12:43:34] <jhonkola_> Issue PYTHON-398 on JIRA claims that a similar error is fixed on pymongo 2.1.1
[12:43:46] <jhonkola_> Any ideas how to fix?
[12:45:11] <joannac> jhonkola_: erm... the bug is to do with sockets not being closed properly.
[12:45:49] <jhonkola_> yes, I have run mongo on similar stack for a year with no problems
[12:46:03] <jhonkola_> the error happens immediately when calling MongoClient constructor
[12:46:21] <joannac> Show us your code :p
[12:46:36] <joannac> Can you make a simple repro script?
[12:47:24] <jhonkola_> joannac: yes, please wait for a few minutes
[12:48:35] <Nomikos> joannac: I would "select" the documents to be grouped with the _id field, as in the search params go in there?
[12:50:03] <Neptu> joannac, question, does the mongod that holds the database as secundary on port 27017 can be added as a arbiter or you really need to define an extra mongod process in the same machine?
[12:50:03] <joannac> yes. put a $match in there and maybe a $limit? I already closed your pastebin
[12:50:52] <joannac> Neptu: I don't understand the question
[12:51:07] <jhonkola_> joannac: the bug is not reproducible with a simple script
[12:51:54] <joannac> jhonkola_: Not really surprising :) You need to figure out the simplest way to reproduce it :)
[12:52:01] <jhonkola_> joannac: Google search suggested that it has something to do with multiprocessing / multithreading, probably gunicorn in this case
[12:52:26] <joannac> jhonkola_: Sure, that makes sense.
[12:52:48] <jhonkola_> joannac: I'll try to set up a simple django / gunicorn setup and try to reproduce there
[12:53:22] <joannac> Neptu: you have a process running on 27017, 27018. Are they both already in your replSet config?
[12:54:09] <Neptu> joannac, Ok I setup a normal mongod in all my machines, and I created another mongod --port 30000 --dbpath /data/arb --replSet rs so on the same server I have 2 mongod one in the normal mongo port an another on port 30000 the first as replica and the second as arbiter. My question is If I can have only one mongod acting like arbiter and database
[12:54:33] <joannac> no
[12:54:37] <Neptu> I have more like 271017 and 30000
[12:54:55] <Neptu> I just want to know if 2 mongod are needed or u can have one doing both things
[12:54:59] <joannac> they need to be separate processes
[12:55:01] <Neptu> arbiter and replica
[12:55:03] <Neptu> ok
[12:55:32] <Neptu> interesting
[12:55:41] <joannac> if they were the same process, once you killed that process, you would be down 2 members
[12:55:53] <joannac> so what was the point of having them both in the first place?
[12:56:10] <joannac> hence, no :) separate processes
[12:56:38] <Neptu> joannac, for the simple reason that you have only 4 machines so for the voting process to happend should be 4 arbiters
[12:56:46] <Neptu> case of 3 servers die
[12:56:49] <joannac> Neptu: NO
[12:57:13] <Neptu> okei so maybe I missunderstand the arbiter task
[12:57:21] <Neptu> without arbiter is no voting
[12:57:29] <Neptu> or normal replica mongod processes vote aswell
[12:57:34] <Neptu> ??
[12:57:42] <joannac> normal mongod processes vote as well...
[12:57:46] <Neptu> aha
[12:57:47] <Neptu> ok
[12:57:56] <Neptu> then it makes quite more sense
[12:58:11] <Neptu> arbiter supose to be outside the server machiens
[12:58:32] <joannac> the only purpose of an arbiter is to get to an odd number so you don't get ties
[12:58:42] <Neptu> can a seconday alone decide to be master?
[12:58:47] <joannac> no
[12:59:04] <joannac> You need a majority to be primary.
[12:59:15] <joannac> The only time 1 is a majority is if there's only 1 member
[12:59:31] <Neptu> ok so is very recomended the arbiter lives outside the mongodb servers
[12:59:37] <joannac> yes
[12:59:58] <Neptu> ok
[13:00:49] <Neptu> now I get the point, in any case makes more sense for a secundary to rely on an arbiter to decide than get a network problem and find yourslef with 2 masters out of sync
[13:01:02] <Neptu> because they cannot see each other
[13:01:03] <Neptu> anyway
[13:01:06] <Neptu> this si fun
[13:28:47] <drag> Hi. I need to implement so sort of paging for some queries. What's th easiest way to do this?
[13:30:12] <cheeser> skip and limit
[13:32:42] <remonvv> That's the easiest way ;) Not necessarily the best.
[13:32:57] <drag> cheeser, the find with numToSkip and batchSize is deprecated. What's the new way to do this?
[13:33:14] <drag> remonvv, ok, what's a better way to do this?
[13:34:13] <taf2> anyone have suggestions on migrating from sharded to NOT sharded? see https://jira.mongodb.org/browse/SERVER-9845
[13:34:20] <remonvv> drag: Neither numToSkip nor batchSize are related to this. Use skip() and limit(). And it is the easiest way to do paging. It's *potentially* problematic because skip is an O(n) operation which means if you need to page to very high page numbers performance will degrade.
[13:34:38] <taf2> have a production system running that was sharded but on a bad key also sharded way before it's needed
[13:34:46] <taf2> would like to migrate without downtime if possible
[13:35:07] <taf2> using the technique in that bug report looks reasonable but wondering if anyone can verify
[13:35:10] <drag> remonvv, alright, so what's a better way to do this? Pull back everything?
[13:36:40] <remonvv> taf2: There's no such thing as sharded before you need it ;) Any production database that has to potentially scale up at some point should start out sharded. If you sharded on the wrong key refer to http://docs.mongodb.org/manual/faq/sharding/#can-i-change-the-shard-key-after-sharding-a-collection
[13:36:45] <cheeser> drag: deprecated? in what api?
[13:36:50] <remonvv> TL;DR though : Always downtime.
[13:37:05] <drag> cheeser, java mongo driver, 2.11.3
[13:37:16] <remonvv> drag: I'm not saying there's a better way, I'm saying that there are times when skip() and limit() may not be the best approach for performance reasons.
[13:37:24] <drag> remonvv, ok.
[13:37:38] <remonvv> drag: If it's for a UI you'll never page to page 102 anyway so it's usually fine.
[13:38:23] <remonvv> drag: If you have a huge leaderboard with 400k players and you need to display the page with player 232,411 on it then you might have to do things differently.
[13:38:27] <remonvv> differently = more complicated.
[13:38:29] <cheeser> skip() isn't deprecated...
[13:38:53] <cheeser> collection.find(new BasicDBObject(...)).skip(n).limit(x)
[13:39:02] <remonvv> None of the cursor methods are.
[13:39:06] <taf2> remonvv: thanks - i've seen that document, but have seen the bug report i referenced here: https://jira.mongodb.org/browse/SERVER-9845 it would appear this strategy could work
[13:39:49] <taf2> let's say i take a server with 3 shards… and drain out 2 of the 3 into just 1 mongod instance
[13:40:06] <taf2> now i'm left with 1 mongod instance and all the data but did not have to suffer downtime
[13:40:06] <remonvv> taf2: It could certainly work, but it's not supported.
[13:40:44] <remonvv> taf2: That's not the end of it though, you still need to unshard the collection by manually removing config metadata, flush the routers, hope everything is still okay, and so forth.
[13:40:57] <remonvv> taf2: Getting all your data on one shard is very easy.
[13:41:22] <taf2> yeah, i'm almost there 1 shard
[13:41:31] <taf2> drain still in progress on one shard
[13:41:39] <remonvv> Right, that's easy and completely supported
[13:41:58] <remonvv> But there's no "unshard collection" command so you'll have to manipulate the config database manually to make that happen.
[13:42:00] <taf2> is the manually removing config metadata part not supported?
[13:42:04] <remonvv> Which, obviously, is risky.
[13:42:22] <remonvv> Well no, I thought that was implied in "manually manipulating config data" ;)
[13:42:24] <taf2> so… at this point it's dump the data and reload it?
[13:42:36] <jhonkola_> joannac: Found a problem in configuration after all. Seems to be working now
[13:43:02] <remonvv> That's the safe route. The risky route is to change config data directly and flush your mongos processes.
[13:43:16] <remonvv> Risky as in, I wouldn't do it on a production environment.
[13:43:37] <taf2> remonvv: got it… and that's because as data is being written it's possible data could be lost?
[13:43:52] <taf2> or could data get corrupted or we just can't say/no because "not supported" ?
[13:43:59] <remonvv> taf2: No, but that's another issue.
[13:44:02] <taf2> s/no/know/
[13:44:16] <remonvv> taf2: Not supported = Don't complain if you lose your data ;)
[13:44:18] <taf2> no it can't get corrupted but maybe data can be lost?
[13:44:24] <taf2> roger
[13:44:31] <taf2> is the data lost from new incoming writes
[13:44:36] <taf2> or lost existing records?
[13:44:46] <taf2> trying to understand
[13:45:06] <taf2> implications of manual changes in config server
[13:45:07] <remonvv> taf2: The route is; stop all writes, stop balancer, remove your sharded collections from db.collections in config db, remove chunks in db.chunks for those collections, execute router flushes on all mongos processes and hope.
[13:45:34] <remonvv> I don't really see how you can lose records other than ones that are being written while it lost chunk information.
[13:45:37] <taf2> got it what about just setting up a replica from the current single shard?
[13:46:01] <remonvv> Doesn't change much, it would replicate the fact that it is sharded.
[13:46:12] <remonvv> You can dump your data, try the risky route and restore if it fails.
[13:46:33] <taf2> i might do that… so it sounds like the risky route would convert things faster than reloading
[13:46:44] <taf2> in my app i can accept lost record data just not for too long...
[13:47:00] <taf2> new record data that is...
[13:47:01] <remonvv> Can always try I suppose but only you know how important your data is.
[13:47:14] <remonvv> Just dump before you have a go.
[13:47:18] <remonvv> And test it locally first.
[13:47:21] <agend> hi all
[13:47:22] <remonvv> And don't blame me if it fails ;)
[13:47:37] <agend> have a problem- when I make update with query: query = {'_id': SON([('u', hash_pk), ('k', 'h'), ('d', ts)])} and upsert=True i get document with _id: { "u" : 567, "k" : "h", "d" : ISODate("2013-10-09T13:36:23.666Z") }. But when I make a update with query {'$or': [{'_id': SON([('u', hash_pk), ('k', 'h'), ('d', ts)])}]}, I got document with _id like this: ObjectId("52555cbdad20bca3410e995b"). So - how can I update(upsert) with query which selects mu
[13:47:37] <agend> ltiple documents and keep the _id with data I want?
[13:47:38] <taf2> remonvv: i'll totally blame you why would you expect anything less ;-)
[13:47:56] <taf2> thanks for the help - i have somethings to test out now
[13:50:39] <agend> have a problem- when I make update with query: query = {'_id': SON([('u', hash_pk), ('k', 'h'), ('d', ts)])} and upsert=True i get document with _id: { "u" : 567, "k" : "h", "d" : ISODate("2013-10-09T13:36:23.666Z") }. But when I make a update with query {'$or': [{'_id': SON([('u', hash_pk), ('k', 'h'), ('d', ts)])}]}, I got document with _id like this: ObjectId("52555cbdad20bca3410e995b").
[13:50:42] <agend> So - how can I update(upsert) with query which selects multiple documents and keep the _id with data I want?
[13:51:46] <kali> agend: what language is this ?
[13:52:01] <agend> kali: python with pymongo
[13:53:31] <Neptu> joannac, I just tested to put down all nodes adn turn on 2 of them... the problem is seems now both are secundary so voting happend
[13:54:26] <agend> kali: but should work the same in others - I need to update mulpitle documents - probably create them (upsert) but when I make query to select more then one I get ObjectId(....) as _id instead of my _id and only one document. What I want is to update/create many documents in one go
[13:55:27] <Neptu> how can i force 2 secondarys to vote and elect a primary?
[13:56:03] <joannac> agend: how will your code generate unique ids?
[13:56:19] <joannac> neptu: howmany members in the set?
[13:56:28] <Neptu> 4
[13:56:32] <kali> agend: well, if you can reproduce the problem in the mongodb shell, maybe more people could help
[13:56:53] <agend> jonnac: like this with pymongo/python: SON([('u', hash_pk), ('k', 'd'), ('d', day_ts)])
[13:56:55] <joannac> 2 is not a majority fir a 4node set
[13:57:15] <Neptu> joannac, 4 same setup as b4 I just removed arbiters and turn off 2 servers
[13:57:35] <agend> i make query like this:
[13:57:36] <agend> query = {
[13:57:36] <agend> '_id': {
[13:57:36] <agend> '$in': [
[13:57:36] <agend> # urls
[13:57:36] <agend> SON([('u', hash_pk), ('k', 'h'), ('d', hour_ts)]),
[13:57:37] <agend> SON([('u', hash_pk), ('k', 'd'), ('d', day_ts)]),
[13:57:40] <agend> SON([('u', hash_pk), ('k', 'w'), ('d', week_ts)]),
[13:57:41] <agend> SON([('u', hash_pk), ('k', 'm'), ('d', month_ts)]),
[13:57:43] <agend> SON([('u', hash_pk), ('k', 'y'), ('d', year_ts)]),
[13:57:49] <cheeser> please don't paste here
[13:57:54] <agend> sry
[13:58:04] <joannac> agend: pastebin
[13:58:07] <Neptu> so 2 mongod servers up an running both are secondary
[13:58:22] <joannac> Neptu: 2 is not a majority for a 4 node set!
[13:58:30] <Neptu> ok
[13:58:47] <cheeser> you need an odd number even if one is an arbiter
[13:58:54] <Neptu> ok
[13:59:07] <joannac> Neptu: get an arbiter. Or start another mongod.
[14:00:02] <Neptu> joannac, starting so in that sense u need n/2 +1 to get majority
[14:00:21] <joannac> you need a strict majority, yes
[14:00:23] <Neptu> so only n/2 -1 of your servers can die
[14:00:38] <Neptu> after that is no master selected
[14:00:45] <joannac> correct
[14:00:48] <Neptu> ok
[14:00:50] <Neptu> great
[14:01:41] <joannac> agend: I don't understand how you think you can get unique _ids from a single-line update
[14:02:21] <Neptu> joannac, what I do not understand why should be the majority on all the servers and not the majority on all servers still alive
[14:02:44] <joannac> Neptu: because you have no idea if the other servers are dead on on theother side of a network partition
[14:03:17] <joannac> are dead or on the other side*
[14:03:22] <Kim^J> Neptu: When you have two servers, if one dies, how should the other one know it can be primary? It can't vote on itself.
[14:04:02] <Kim^J> It needs to ask more servers if the server it thinks is dead is actually dead.
[14:07:02] <agend> joannac: when I make: query = {'_id': SON([('u', 'blah'), ('k', 'h'), ('d', 'ts')])} mongo_collection.update(query, update, upsert=True) I get upserted document with _id = {u: 'blah', k: 'h', d: 'ts'}
[14:07:24] <agend> joannac: I thought I can get the same thing with query which selects mulitple documents
[14:07:48] <joannac> agend: what's the update part?
[14:07:52] <agend> joannac: I think I should precreate the documents first and then maybe it could work
[14:08:14] <agend> joannac: update command: mongo_collection.update(query, update, upsert=True)
[14:08:24] <Neptu> in case of network partition lets say on thsi setup you have 7 machines if 2 secondaris and arbiter are still alive can not decide for a master what means I'm n/2 -1 fail tolerant so if the net gets segmented one segment will be able to survive and sync later in case of failure of the other 4 boxes the rest alive can not survive
[14:08:48] <Neptu> find interesting this voting method but I think there is room for improvement
[14:08:56] <joannac> agend: "update" is a variable, yes?
[14:09:11] <agend> joannac: and update is a dict with data like $inc
[14:09:18] <agend> joannac: yep
[14:09:32] <joannac> agend: right. pastebin it.
[14:10:17] <agend> joannac: the update part is not a problem, its working, for one document
[14:10:21] <joannac> does it have something for the _id field?
[14:11:06] <agend> joannac: nop - I want to update about 40 documents (which may not exist yet) at one go
[14:11:31] <joannac> okay... so mongodb fills in its own _id
[14:11:35] <agend> joannac: when I make query for one doc - I dont have to put _id in update
[14:11:37] <joannac> What do you expect to happen?
[14:11:51] <joannac> agend: even when the doc doesn't exist?
[14:12:45] <agend> joannac: I thought if I make query with _id $in [40 ids] it would create and update the docs like for one doc - and keep the _id for me
[14:13:06] <agend> joannac: not going to work this way?
[14:18:24] <joannac> agend: http://pastebin.com/qm1dUef0
[14:23:49] <bhangm> is there a way to force initial sync of a new replica set member from the primary?
[14:24:25] <cheeser> you shouldn't need to force anything
[14:24:47] <bhangm> if I don't it pulls it from a secondary
[14:24:56] <bhangm> I think based on ping times
[14:25:30] <bhangm> and replSetSyncFrom only takes effect after initial sync
[14:26:21] <joannac> bhangm: Why do you want it to sync from primary and not secondary?
[14:27:35] <bhangm> I need it to sync from primary b/c of some cleanup that was run to drop databases. I couldn't issue the drop on the primary b/c it takes a global write lock *and* does a flushAll for every single drop
[14:27:53] <bhangm> so I had to issue the drop on the secondary and bring it back in and promote it
[14:28:39] <joannac> bhangm: "To affect the sync target for the initial sync, run rs.syncFrom() operation before initial sync."
[14:28:53] <joannac> from http://docs.mongodb.org/manual/tutorial/configure-replica-set-secondary-sync-target/
[14:29:00] <cheeser> you could always remove that secondary and readd it.
[14:29:07] <cheeser> though that's a very big hammer
[14:30:17] <joannac> bhangm: so now you have a primary with no db, and N secondaries with the db? and you're going to initial sync them all?
[14:30:31] <bhangm> joannac: no, I didn't drop all
[14:30:34] <joannac> oh, pull them out one by one and drop the db?
[14:31:05] <bhangm> I dropped a set of dbs, brought that secondary back in and made it the primary (after catching up)
[14:31:23] <bhangm> now I want the other secondary and the old primary to basically refresh their data set from the new primary
[14:31:43] <bhangm> seeding is one way to do it but unfortunately there are constraints that prevent me from doing that
[14:33:32] <bhangm> how exactly does one run rs.syncFrom before initial sync ? Doesn't initial sync happen as soon as the member starts up? Or do I have to remove it from the set, restart it and run rs.syncFrom and add it back to the set ?
[14:39:08] <agend> joannac: ok - it's preserved - for existing document. But when it creates a new one (thanks to upsert) we have 2 cases - when query for update selects one document by _id: i have a new doc with _id from query. But when I have query with _id $in list of 40(for example) expected _id's - I get 1 new document with _id = ObjectId. I guess it is how mongo works. Now I try to precreate the documents and update them with multi and it works
[14:40:15] <joannac> bhangm: I guess so; I haven't tried setting an initial sync target.
[14:40:56] <bhangm> joannac: ok, thanks. I guess I could try that first and see if it works
[14:41:12] <agend> when I make bulk insert - and some of the docs already exists - are they destroyed? Is there any way to make bulk insert and preserve already existing docs?
[14:48:12] <bakis> hey guys is there a way to skip the config user accounts on mongodump and mongorestore? I'm dumping from one branch and loading to another and it's overwriting the access keys.
[14:49:16] <drag> agend, from my quick testing, it throws an exception when I try to add a document that's already in the database with the java driver.
[14:50:08] <agend> drag: thanks - same thing for me from python
[14:53:44] <bhangm> joannac: no luck with that approach I'm afraid. Might have to try blackholing traffic to existing secondary instead
[14:59:06] <bakis> okay.. is there a way to specify multiple collections in mongodump? or specify NOT a collection? can't seem to find it in the docs
[15:13:16] <bakis> Could anyone tell me a better way to do this? I'm trying to transfer data from my production branch to my feature branch for real seed data. How is this not a common problem?
[15:14:22] <cheeser> branches? what?
[15:15:05] <bakis> sorry. i'm using mongohq on heroku. the config variables are being pulled down and when i load it into the next branch it's overwriting the mongohq credentials
[15:41:47] <drag> in the Java driver, if I want to check if field A contains a value from a list of values, I can do that with BasicDBOBject().put("A", ["1", "2", ...]), correct?
[15:43:01] <kali> drag: it sounds like you need a "$in"
[15:45:34] <drag> kali, so BasicDBOBject().put("A", new BasicDBObject("$in", ["1", "2", ...]))?
[16:25:09] <Nomikos> Is it possible to project the second item in an array value, in aggregate?
[16:25:46] <cheeser> new BasicD
[16:25:49] <cheeser> bah
[16:26:00] <cheeser> drag: figure it out yet?
[16:35:18] <jamesshijie> Quick beginner question about mongo find() -- Do I need to check the existence of a key before I try to access it? It seems to work if I don't, but is it slower to do that, or just bad practice?
[16:36:05] <cheeser> if you find() against a property that doesn't exist, you'll simply get no results.
[16:39:36] <jamesshijie> ok, that I understand. So in my collection, I have a variety of objects each containing the key module_id, course_id, or organization_id. If I search for module_id, and there are other documents that don't have that key, will they be intelligently ignored?
[16:39:50] <jamesshijie> Or do i need to check existence first for speed purposes?
[16:40:10] <Nomikos> they'll be ignored
[16:40:15] <jamesshijie> I realize these questions are probably elementary
[16:40:35] <Nomikos> I'm like, 15 minutes ahead of you, don't feel bad :-p
[16:41:17] <jamesshijie> Nomikos: Hahaha. Thank you. I've been at this for about a day or so. I love it so far, but a few paradigm shifts need to happen in my mind.
[16:41:25] <kali> jamesshijie: if you ask for a key with no index, mongodb will scan the collection
[16:41:52] <kali> jamesshijie: even if no document uses it
[16:42:10] <jamesshijie> kali: Gotcha. I'll look up indexes then
[16:42:51] <Nomikos> I always forget about those..
[16:44:12] <jamesshijie> kali: If I had a collection with equal amounts of documents containing one unique key (module_id, course_id, organization_id, etc...) Would indexing be the way to go for that?
[16:44:30] <kali> i don't understand what you mean
[16:44:44] <Nomikos> jamesshijie: might it make sense to split the collection into different collections based on the type of data?
[16:45:00] <jamesshijie> Nomikos: Yeah, you're probably right
[16:45:08] <jamesshijie> I'll just do that
[16:46:57] <Nomikos> Q: in the Mongo CLI, if I do b.find({foo: 'bar'}) where b is a collection it outputs a bunch of docs. how do I store those docs in a variable?
[16:47:11] <Nomikos> do I have to forEach? assignment doesn't seem to work
[16:47:16] <Nomikos> .. I'll forEach
[16:47:50] <cheeser> var res = db.collection.find()
[16:48:09] <kali> maybe .toArray()
[16:49:14] <Nomikos> cheeser: 'var' makes the difference ?
[16:50:06] <cheeser> yep
[16:50:06] <Nomikos> hmm.. it doesn't remember the data, as such..
[16:50:26] <kali> toArray(). find() returns a cursor
[16:50:29] <Nomikos> if I just enter 'res' on the next line, it outputs the data, but then it's gone. I guess that's the cursor emptying itself
[16:50:49] <cheeser> could be, yeah
[16:50:50] <Nomikos> thanks both, got it now
[16:51:40] <cheeser> calling .toArray() will exhaust the cursor and give you an array of the results
[16:51:41] <maasan> you can also give try of https://github.com/TylerBrock/mongo-hacker
[16:53:18] <cheeser> heh. he's my desk neighbor.
[16:53:39] <kali> maasan: ho, that's nice.
[16:54:48] <maasan> cheeser: Oh thats great. Thanks to your neighbhor for cool terminal.
[16:55:21] <kali> cheeser: +1
[17:06:14] <kali> cheeser: i like it so much, there's aready a pull request.
[17:06:52] <cheeser> :)
[17:14:28] <Nomikos> is there a shortcut to delete a certain attribute of all documents in a collection?
[17:14:52] <kali> Nomikos: update with multi and $unset modifier
[17:21:31] <Nomikos> kali: cheers. maybe I should go home if I can't figure out those things anymore >.>
[17:22:42] <cheeser> there's a lot to be said about stepping back from a problem for a bit...
[17:34:56] <defaultro> am I right that in MongoDB, there is no size on fields?
[17:40:36] <Nomikos> defaultro: you don't specify a size. I don't think it knows what size the data in the fields is
[17:41:01] <defaultro> that means, we can put whatever length of string it is
[17:41:02] <Nomikos> like, "select lenght(field1)" has no equivalent in mongodb
[17:41:09] <defaultro> k
[17:41:14] <Nomikos> up to the max documentsize of 16 MB
[17:41:22] <defaultro> ok
[17:41:27] <defaultro> so there is a limit
[17:41:33] <defaultro> is there a blob in mongodb?
[17:41:49] <Nomikos> if you need larger, there is gridfs or somesuch, but now I'm talking about something which I heard late at night in a pub on a stormy night
[17:42:04] <defaultro> :) k
[17:42:34] <cheeser> there's no max size of a string, say, apart from the max document size
[17:43:32] <defaultro> k
[17:43:45] <defaultro> all the chekcing is done in the app
[19:52:33] <dxd828_> I have started my mongodb install with the --auth option. When I try and add a user admin using: db.addUser() I get a throw "password can't be empty". Anyone know whats up with that?
[19:53:52] <retran> http://docs.mongodb.org/manual/reference/method/db.addUser/
[19:54:47] <retran> what confuses you about that error message, dxd828_?
[19:55:04] <dxd828_> retran: the password isn't empty
[19:55:22] <dxd828_> db.addUser( { user: "admin", pwd: "mycoolpassword", roles: [ "userAdminAnyDatabase" ] } )
[19:56:32] <retran> http://docs.mongodb.org/manual/reference/privilege-documents/#<database>.system.users.pwd
[19:56:43] <retran> you are using it wrong
[19:57:53] <retran> wait..
[19:57:56] <retran> it looks fine
[19:58:24] <dxd828_> retran: okay, I did this before as well: db = db.getSiblingDB('admin');
[19:58:35] <retran> what is your db.version()
[19:58:50] <dxd828_> retran: 2.2.3
[19:59:21] <dxd828_> retran: ah just realised, that's really old right?
[19:59:45] <cheeser> it is.
[19:59:59] <cheeser> in that line 2.2.6 is the latest and 2.4.6 is the most current
[20:01:11] <dxd828_> cheeser, ah I did this install quickly, must of used the packages in the cents repo doh!
[20:01:52] <retran> maybe use mongo's yum packages
[20:02:33] <retran> they have a yum repo http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
[20:02:52] <dxd828_> retran, yeah will do. I used them on my desktop and I managed to get auth working the same way. That's why i wondered why it wasn't working :) thanks for the pointers
[20:03:15] <cheeser> if you're on ubuntu, there's a 10gen repo you can add to get the latest ones we build.
[20:03:51] <retran> that's what i use, ubuntu
[20:04:40] <dxd828_> Ah, I'm on centos. Ill just use http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
[20:49:08] <ZacGod> Hello!
[20:49:24] <retran> Hi dammit!
[20:49:31] <ZacGod> :D
[20:53:35] <ZacGod> Should I run config servers on their own VM?
[20:55:29] <retran> not sure that question can be meaningfully answered 'yes/no'
[20:56:00] <ZacGod> Yeah I understand that :)
[20:56:12] <ZacGod> I was just looking for some advice on the subject
[20:57:00] <retran> so far, i'm only in devops phase of my mongo projects
[20:57:15] <retran> interesting question though
[20:57:18] <ZacGod> ah
[20:57:38] <ZacGod> Our application is in production using mongo.
[20:57:51] <retran> cool
[20:58:10] <retran> you have replication live for it?
[20:58:13] <ZacGod> One of our clients is pushing back on using seperate vms for config servers but i can't find any documentation talking about the subject.
[20:58:21] <ZacGod> Yeah we have replication and sharding.
[20:58:57] <retran> without knowing any more, looks like a quesiton of resource usage
[20:59:26] <retran> are the VPS systems particularly pricey?
[20:59:50] <ZacGod> That is what the client is saying
[21:00:03] <retran> it looks ideal to have config servers be separate
[21:00:15] <retran> since tehy're another mongod instance
[21:01:07] <retran> i had a client who never took any of my deployment and maint advice
[21:01:13] <retran> i now ignore his calls
[21:01:40] <retran> they tend to be like "hey.. our site is really slow, whats wrong"
[21:01:48] <retran> and "hey, can you help our server crashed"
[21:01:48] <ZacGod> yeah...
[21:02:14] <ZacGod> I would ignore those calls also
[21:03:33] <joannac> ZacGod: for production? I would say yes.
[21:03:58] <ZacGod> Thanks, joannac :)
[21:04:06] <ZacGod> Thats what I was thinking.
[21:04:41] <ZacGod> I'm searching on the website for a "best practice" on the subject.
[21:05:33] <MattAFT> Hi, I am having trouble with a Mongo Replica set....who wants to help :)
[21:05:41] <ZacGod> Whats the trouble?
[21:06:51] <MattAFT> It can't write remotely (from my local) machine....the boxes are hosted on aws and from an app server on another ec2 instance, writes work fine
[21:07:15] <MattAFT> Whenever I try to write remotely I get "Unable to connect to a member of the replica set matching the read preference Primary".
[21:07:21] <MattAFT> But can read fine
[21:07:28] <MattAFT> This is with c# driver 1.8.1
[21:07:36] <ZacGod> hmm
[21:07:40] <MattAFT> connection string looks like mongodb://mongobox1,mongobox2,mongobox3/dbname?replicaSet=replicasetname&readpreference=primaryPreferred
[21:07:53] <MattAFT> I also found that the sometimes (not sure the conditions), when I take down the master, I can then write fine from local and when I bring the machine back up it syncs properly. But as soon as I bring the machine back up, I can no longer write from local
[21:08:35] <MattAFT> also If I change my connection string to only connect to primary, then the write goes through fine, but obviously does not replicate to the other boxes.
[21:08:58] <retran> is there an awesome book i can learn about mongo deployment stories and strategies
[21:09:12] <joannac> What. Why does it not replicate to the other boxes?
[21:09:30] <MattAFT> cause I changed the connection string to only point to one box
[21:09:37] <MattAFT> or got rid of the replica piece
[21:11:02] <joannac> Your replica set doesn't cease to be a replica set just because your connection string changes...
[21:11:33] <MattAFT> if I just specify one box in the connection string....it will still replicate?
[21:11:47] <MattAFT> the driver doesn't have to know about the other boxes?
[21:13:08] <ZacGod> Matt, if the C# driver is like the java driver it will check to see if there is a replicaset when it connects.
[21:14:05] <MattAFT> ok
[21:14:35] <MattAFT> so that one instance tells the driver the address of the secondaries?
[21:14:55] <ZacGod> It checks to see which instance is primary
[21:15:06] <MattAFT> but it only has the address of one box
[21:15:11] <MattAFT> or instance
[21:15:16] <MattAFT> how does it know about the other instances
[21:15:35] <joannac> MattAFT: when you set up a replica set every node knows about all the other nodes in the replSet
[21:16:06] <MattAFT> right...but what about the driver coming from the app server?
[21:16:44] <ZacGod> I would specify all of the servers
[21:16:54] <MattAFT> ok
[21:16:56] <ZacGod> afaik they all need to be online
[21:17:28] <MattAFT> I defintely expereince different behavior based on the connection string
[21:17:42] <MattAFT> so not sure if that is related or not
[21:18:01] <MattAFT> but the main issue is being able to write at all when my connection string has all 3 instances
[21:18:19] <joannac> so you can connect but not write?
[21:18:31] <MattAFT> I can read
[21:18:42] <joannac> Is your replica set actually up?
[21:18:45] <MattAFT> and I can write to the master only when I change the connection string
[21:18:53] <MattAFT> yes everything is working fine from my app server on aws
[21:18:57] <MattAFT> just not form my local
[21:19:04] <joannac> same code?
[21:19:10] <MattAFT> yes sir
[21:19:13] <MattAFT> or m'am
[21:19:57] <joannac> can you connect just via the mongo shell locally?
[21:20:04] <MattAFT> yes
[21:20:12] <MattAFT> all of them
[21:20:48] <joannac> and you can write?
[21:22:40] <MattAFT> yes
[21:22:48] <MattAFT> I wrote to master and it replicated
[21:22:52] <MattAFT> through console
[21:22:59] <MattAFT> c# driver issue?
[21:23:53] <joannac> well, it works on your app server.
[21:24:13] <joannac> so something about the combination of your local setup + c# driver, most likely.
[21:25:50] <MattAFT> is there any other additional tools to use to investigate something like this or logs or support?
[21:42:50] <joannac> i would want to see the code you're running on both servers, to make Sure it is the same
[21:43:01] <joannac> and hear about your setup