PMXBOT Log file Viewer

Help | Karma | Search:

#mongodb logs for Tuesday the 16th of July, 2013

(Back to #mongodb overview) (Back to channel listing) (Animate logs)
[00:00:18] <pplcf> what should I use for simple distinct count? just collection.distinct.length or aggregate? which would be faster?
[00:01:05] <retran> aggregating on your mongo client?
[00:01:20] <pplcf> node native
[00:01:26] <retran> why wouldn't that be slower
[00:01:32] <retran> of course it would be
[00:02:06] <retran> the server is going to have a faster way of counting than your client
[00:03:04] <pplcf> aggregate framework is client side feature?
[01:13:33] <mrapple> why does print() and printjson() output nothing in the finalize part of map reduce?
[01:13:38] <mrapple> any way to see debug info?
[01:25:43] <maeldur> Hey if anyone is around I have a sharding/replication question
[01:38:11] <dan__t> 'evening. pretty new to mongo.. reading up on config object definition, as shown in the replica set tutorial. wondering if i can drop that configuration in a file and then use that as stdin or piped to mongo?
[01:39:11] <dan__t> in the man page i read a lot about noninteractive use. i'm hoping this functionality extends in to replication pieces.
[01:39:33] <dan__t> mm, also from the man page, mongo script1.js script2.js script3.js
[01:51:40] <maeldur> are replica sets aware of what shard they're in, or is that all handled by the config server?
[02:01:12] <dan__t> i have what i think is a valid config for importing some replica set data in to... I run it through mongo and I don't see anything show up with rs.status(). http://pastebin.com/uUY1nRHR
[02:31:02] <dan__t> is there a way to initialize replication even when other replicas are unavailable? thinking down the lines of, eventually, they will all be up at the same time
[02:31:24] <dan__t> I was looking in to rs.slaveOk() but I don't think that's quite what I want
[02:32:42] <das3in> hi, I'm really new to backend development and am specifically having a hard time wrapping my mind around efficient data modeling. I want to have a dropdown menu where the user can choose to charge either hourly or a flat rate. Is the best way to do that est_cost_hourly = {type: Number, hours: Number}, est_cost_flat = {type: Number} as 2 separate fields in my Schema, and leave one of them null?
[02:57:22] <jsonperl> what privs do I need to db.setProfilingLevel(1), it gives me an unauthorized error. I'm already "userAdminAnyDatabase", "readWriteAnyDatabase", "clusterAdmin", "dbAdminAnyDatabase"
[03:05:40] <maeldur> if anyone was wondering, the answer to my previous question was yes, the mongo repl set members remember about the shard config and need to be restarted before a new shard config work
[03:27:02] <brizna> Does anyone know the running time of db.foo.find({"indexed_key": "bar"}).count() and/or how it works?
[03:36:18] <caitp> okay, so
[03:36:23] <caitp> here's the thing
[03:37:04] <retran> oh boy i can't wait to hear
[03:38:19] <caitp> I need to find a list of documents within a collection, where a given ObjectId is found in a subdocument array of documents in that collection , and it's not an array of ObjectIds for some reason, so I don't think I can use $in, but rather just an array of objects with a single key pointing to an ObjectId
[03:38:26] <caitp> and I have no idea what a query for this would look like
[03:39:08] <caitp> in an array of subdocuments*
[03:39:36] <retran> the $ operator
[03:39:51] <retran> collection.$.subdocfield
[03:40:09] <retran> ad infinium
[03:41:05] <retran> ccit's not often that mysqld is configured to use the same system tmp dir
[03:41:12] <retran> shit wrong paste
[03:41:18] <retran> http://docs.mongodb.org/manual/core/update/#update-a-document-element-without-specifying-its-position
[03:42:02] <caitp> the documentation says it's regarding updates as well, but this is a read only query
[03:42:17] <caitp> i dunno if it's a misnomer or what
[03:43:12] <caitp> I've got an object, I need to find a list of objects where that object is referenced in a subdocument, because someone had very interesting ideas when designing this system
[03:43:25] <retran> you would refer to array position then, i think
[03:44:23] <retran> maybe i'm not understanding your question
[03:44:33] <retran> are you just wanting to link between two objects?
[03:45:54] <caitp> a User is granted access to areas of a Campus by being granted a list of Zones (groups of Locks) for which they are allowed to enter
[03:46:13] <caitp> the Lock sends a message to a webserver saying "hey, someone is trying to open me, here's their RFID number, can I open up for them?"
[03:46:58] <caitp> the webservice needs to say "okay, let me find you based on where the request came from... okay I've found you, now lets see if this user is allowed to open you, by checking if you appear within any of the Zones that they have access to"
[03:47:58] <caitp> so, based on a Lock (which is a member of zero or more sets of Zones/Groups), I need to find the list of Zones for which it is in fact a member, and see if User is authorized for any of those Zones
[03:48:42] <caitp> does that explain what the query needs to do, or is that just confusing?
[03:51:13] <retran> tl;dr
[03:51:29] <caitp> heh, alright
[03:51:35] <retran> just kiddin i read it
[03:52:23] <retran> how many collections are there
[03:52:34] <retran> is this all stored in 1 collection?
[03:53:33] <caitp> nope :( users, devices, zones, and rfids are the only ones that matter for this operation, but they're all separate collections
[03:53:40] <retran> oh
[03:53:47] <retran> that's not so bad
[03:54:09] <brizna> Zones has { Locks: [{}, {}, {}] } as part of it's documents, and you want to query Zones for Zones that have a particular lock in its Locks array?
[03:54:31] <caitp> exactly
[03:54:51] <brizna> ok, I have no idea and just wanted to clarify :), sorry!
[03:55:00] <caitp> heh :)
[03:55:30] <retran> http://stackoverflow.com/questions/11823296/mongodb-find-subdocument-in-array-matching-parameters
[03:55:49] <retran> is that stackoverflow describing this problem?
[03:56:16] <brizna> that looks like a bingo to me
[03:57:42] <caitp> hmm, well I'll experiment
[04:02:10] <caitp> well
[04:02:18] <caitp> I can't tell if this query works or not with this data :(
[04:02:50] <caitp> oh, apparently it doesn't
[04:02:55] <retran> just remember, it will be your fault if women get raped
[04:03:26] <caitp> well luckily (or not!) there aren't that many working at these nerd factory startup companies I guess, so they should be okay!
[04:06:58] <caitp> oh it worked, horray
[04:07:29] <caitp> thanks folks
[04:30:54] <thomasdavis> Gday guys, if upgraded my ruby gems mongo and bson and now it throws an error on my keys with '.' (BSON::InvalidKeyName: key must not contain '.' or '$')
[04:31:12] <thomasdavis> the only problem is I just cannot fix the data because there is a decent amount
[04:31:22] <thomasdavis> does anyone know if I could suppress this error or some solution?
[04:55:39] <crudson> thomasdavis: I'd fix it if you could. Looks like check_keys is forced to true for saving documents.
[05:02:43] <Senor> Have anyone try memcached plugin for mysql?
[05:56:15] <pplcf> how to use "$ifnull" in aggregation?
[05:57:05] <pplcf> I want to provide default value for nullish field
[06:04:34] <pplcf> nevermind
[06:50:09] <SrPx> Hello. What happens if I have to make 2 updates on my database, but my process crashes between the call to the first and the second `set`? Will this leave the db in an invalid state?
[07:45:21] <[AD]Turbo> hola
[08:57:46] <pithagorians> hey guys. can i have 4 members replica set with one master, second slave and 2 arbiters ?
[11:43:50] <remonvv2> \o
[12:04:58] <_pash> hello is it dangerous to make user._id's publicly available?
[12:07:48] <remonvv> No.
[12:08:27] <remonvv> They're just identifiers. It's only dangerous if you expose something in your application that allow other people to do something with that information
[12:09:11] <_pash> i am trying to make a platform like a social network. where each user has a profile picture, i am storing each users image path in the database, part of the path where their image is stored is there id, maybe you could suggest a more efficient way of storing images?
[12:13:33] <remonvv> E.g. if you blindly make a REST service /user/{userId} and you return all data for that user then yes, potentially dangerous
[12:15:23] <_pash> ok i understand, maybe you could answer the second question? remonvv
[12:17:52] <remonvv> _pash, no that sounds reasonable. That's how most people including us do it. E.g. www.yourawesomething.com/users/profile/{userid}/avatar_small.jpg
[12:22:24] <_pash> thanks remonvv
[12:26:48] <remonvv> np
[12:27:01] <rspijker> he's already gone man, too slow :)
[12:46:01] <remonvv> Ah one of those. Ask question, get answer, gone.
[13:08:33] <judu> Hi, db.addUser({user: "someroot", pwd: "azerty", roles: ["userAdminAnyDatabase"]}) issues the following: Tue Jul 16 15:07:17 uncaught exception: password can't be empty.
[13:08:35] <judu> Any idea ?
[13:12:49] <judu> hum… my bad… I'm using mongodb 2.0.4.
[13:59:27] <hyperb> looking for some n00b help
[13:59:54] <hyperb> I need to output db.collection.find() to a text file.
[14:03:13] <rspijker> why not just use mongodump or mongoexport?
[14:03:43] <hyperb> Hey now, I said I'm a n00b. Didn't know about those. :)
[14:05:18] <rspijker> if you, at some point, want to put the data back into some mongod instance, mongodump would be the best choice
[14:05:20] <hyperb> I'm reading the help now... But I'll tell you what I'm trying to do in case there's a better way.
[14:05:29] <rspijker> please do
[14:05:42] <hyperb> I'm using graylog2, which uses mongodb. I had never heard of mongodb before then.
[14:06:09] <hyperb> I need to batch-create a bunch of users with the same profile settings. There's no functionality for it from within Graylog2.
[14:06:32] <hyperb> I did some testing yesterday and I can do it from the mongodb interface and it works fine. I tested importing a .js script and it works.
[14:07:03] <hyperb> So I want to export the list of streams and then run that through a JS for loop to create the users.
[14:07:26] <rspijker> you *could* do that in the js as well
[14:07:46] <rspijker> if you are already loading the js, you can simply put the db.collection.find() in there
[14:07:53] <rspijker> then use the resulting cursor
[14:07:53] <hyperb> I need to manually select which streams though
[14:08:02] <rspijker> "manually"?
[14:08:12] <hyperb> To create the initial lists
[14:08:16] <hyperb> once
[14:08:44] <rspijker> db.collection.find({"streamID":{$in:["id1","id2",…,"idn"]}})
[14:09:00] <rspijker> that would give you a result with only streamIDs in the array
[14:09:16] <rspijker> does that help? :)
[14:10:10] <rspijker> point is, you can query the database for some criterium and then use the resulting cursor to do the magic you were planning on the text file
[14:11:01] <hyperb> Right. I realize that. If it were something like 'add all streams beginning with "dev" to this group of users' then yeah.
[14:11:43] <hyperb> I don't have the rights list yet, I was just guessing it was not going to make sense. Based on past experiences with the devs.
[14:11:56] <hyperb> The devs here at work. Not the mongo or graylog devs
[14:15:55] <rspijker> alright, do you have enough of an answer to solve your problem?
[14:16:07] <rspijker> or at least some starting point
[14:16:30] <hyperb> Yeah, I think so. Thanks.
[14:17:57] <kertz> When setting up replica sets, should the connection from code be made only to primary of the replica set or all members of the set?
[14:18:29] <rspijker> kertz: you can set up the connection string to connect to all members
[14:18:38] <rspijker> otherwise you have a problem if the primary ever dies
[14:19:58] <kertz> rspijker, thanks. :)
[14:20:52] <rspijker> kertz: see also here: http://docs.mongodb.org/manual/reference/connection-string/
[14:21:40] <kertz> rspijker, thanks.
[14:21:46] <rspijker> np
[14:31:05] <Nodex> kertz : you can force reads to a secondary if you need to
[14:31:21] <Nodex> just simply feed in a different DSL into your driver
[14:32:16] <kertz> Nodex, but will I always get the latest data?
[14:33:05] <Nodex> depends on your write concern
[14:33:40] <Nodex> even with full write concern it's not garunteed unfortuantely
[14:35:04] <Chocobo> Hi all. In a replica set is there an easy way to force a different host to be master?
[14:56:44] <rspijker> Chocobo: http://docs.mongodb.org/manual/reference/method/rs.stepDown/
[15:00:31] <caitp> http://pastebin.mozilla.org/2640258 how does this make you feel
[15:02:04] <neagix> hi there! I have the classic newbie question (yes, I did some searches already). if I update an object then the next read operation is not guaranteed to fetch the last version of the object, right?
[15:02:59] <Nodex> correct
[15:03:21] <Nodex> unless it's on the same driver connection - you will have to get confirmation on that though
[15:03:44] <neagix> Nodex: thanks. because I have been saying that and people looking at me like if Im' crazy
[15:04:24] <caitp> it's okay to be crazy
[15:04:26] <_pash> hello, i have a form with an input file field. can i submit the form somehow as soon as the user selects a file?
[15:04:50] <caitp> is that a mongo-related question?
[15:04:59] <Avish> hi all. I have an issue with mongodump (using mongo 2.4): when I dump an entire collection, I get a metadata.json file for each collection that includes its indexes; but I also get a system.indexes.bson which includes the same information. How come?
[15:06:21] <caitp> for file inputs in html, you can bind the onchange event and send an XHR request to the server, if that's what you want to do
[15:06:42] <neagix> caitp: I think it's valid for all NoSQL engines, but can't say for sure. and I only use MongoDB
[15:07:03] <caitp> but it's not really a database question yeah?
[15:07:04] <caitp> that sounds more like generic web dev
[15:07:17] <caitp> oh wait, you asked something else
[15:07:28] <neagix> :P
[15:08:56] <caitp> anyways, I kind of want to hit my colleagues for writing queries like this, someone tell me if it's okay to feel like that http://pastebin.mozilla.org/2640258
[15:14:32] <Nodex> what a mess
[15:15:16] <caitp> i don't even want to try and un-mess it :(
[15:16:08] <remonvv> That's spectacularly dodgy code.
[15:16:55] <Nodex> I would shoot someone if they presented me with that
[15:17:02] <caitp> it's not clear why all of the subdocuments look like [{foo_id}] instead of just [ObjectId]
[15:17:35] <Nodex> ObjectId is only one field
[15:18:04] <remonvv> Nothing about that is clear ;)
[15:18:19] <caitp> but instead they have subdocuments of objects containing a single field which is an ObjectId
[15:18:25] <remonvv> Any bit of code that takes longer to decipher than to write if you know the specs is bad code.
[15:28:34] <Chocobo> rspijker: thanks
[15:38:11] <Nodex> caitp : the author has probably made many joins inside the App / ORM
[15:38:19] <Nodex> so he needs his fingers breaking too
[15:39:54] <hyperb> Is there a built-in method to copy a field from one document to another/
[15:39:55] <hyperb> ?
[15:40:11] <remonvv> No
[15:40:22] <hyperb> I'm trying this:
[15:40:47] <remonvv> WHICH PART OF NO IS CONFUSING YOU?!?!
[15:40:54] <remonvv> Haha, I kid. Go on.
[15:41:03] <Nodex> you cannot reference part of a document in another one unless you're map/reducing
[15:41:24] <hyperb> db.users.update({"name":"new"},{set:db.users.find({"name":"old"},{"field":1,"_id":0})})
[15:41:51] <remonvv> Wait...what?
[15:42:02] <Nodex> hyperb : you cannot do sub queries like that
[15:42:24] <hyperb> I want to copy the "field" field from "old" to "new"
[15:42:39] <remonvv> hyperb, basically no native operation exists where the content of document A can affect the content of document B
[15:42:42] <Nodex> you can't do it directly unless you run some javascript
[15:42:55] <hyperb> remonvv: Gotcha.
[15:43:17] <hyperb> But I can do the db.find() and store it in a variable, then run the db.update(), right?
[15:43:23] <remonvv> Sure
[15:43:25] <Nodex> yup
[15:43:25] <hyperb> I like one-liners.
[15:43:40] <Nodex> everything is a one liner with compression :)
[15:43:48] <remonvv> f = db.find().next().yourField; db.update({..}, {$set:{newField:f}})
[15:43:48] <hyperb> But my logic should work, right?
[15:44:13] <remonvv> Well, it can work. It's not safe from a concurrency point of view.
[15:44:34] <hyperb> safe? concurrency?
[15:45:22] <remonvv> Yes. Imagine something updating the value of the field of the old document between you reading its value and writing it to the new document.
[15:45:49] <remonvv> Mind you that either may not be possible or you might not care in your application (because you can live with eventual consistency on some level) but it's worth thinking about.
[15:46:00] <hyperb> Ah. Yeah, that's not gonna happen.
[15:46:07] <remonvv> Should be cool then.
[16:40:07] <georiot> hey guys, i'm brand new to mongo, and working on updating 30 or so values in a document at a time using the atomic $inc operator. My query to find the document to update is a point lookup (i.e. _id: "username-date") so that part is fast. The values i'm upsert/incrementing however are nested into a couple arrays, so i can pre aggregate this data at the day and hour levels. (i.e., value,
[16:40:07] <georiot> days.value, days.{day}.hours.{hour}.value, country.{country}.value, days.{day}.country.{country}.value, days.{day}.hours.{hour}.country.{country}.value, etc) Do i need indexes on these searches that happen inside a document after its been selected, or does the index only help to find the document in the first place (i.e., the query part of the operation)?
[17:02:03] <idlemichael> I'm using mongo as a key/value store. I'm store ~900 million entries in the database, and am merely checking for their existence. I don't have any indeces, except hte _id index. The database is about 150GB large as listed in the mongo console. I'm trying to xfer this data to a slave, but the slave NEVER catches up to the master. I'm trying to avoid stopping writes to the master due to it being a production box. Am I
[17:35:53] <pasichnyk> whats the recommended way to use a domain name as an array key?
[17:49:07] <LambdaDusk> anyone have an example for GridStore use in node.js with write streams?
[19:18:54] <kevino_> is there a way to have a node mark itself out of a replicaset for maintenance in 2.0.4?
[19:19:02] <kevino_> it seems like the replSetMaintenance admin command isn't available
[20:56:30] <gregie156> is there a way to make map() function's output minimized, like normal find() output?
[21:10:55] <moein7tl> what is wrong in my query?
[21:11:05] <moein7tl> db.matrix.find({x:1}).count();
[21:12:23] <LesTR> db.matrix.find({"x":1}).count();
[21:14:10] <czajkowski> This may be of use to some folks here - http://www.lczajkowski.com/2013/07/16/making-it-simpler-to-get-sponsorship-when-needed-from-10gen/
[21:23:02] <harenson> czajkowski: great, thanks :)
[21:25:31] <czajkowski> np
[21:34:22] <maeldur> anyone have any guidance for what a reasonable pool size for mongos instances in production?
[21:45:33] <cybertoast> the documentation for mongorestore says that if i supply --username without --password i'll be prompted for password. but this does not seem to be the case. is there some order that i need to follow? for example `mongorestore --drop --host localhost --port 27017 --db my_db --username admin_user /path/to/dump/` does not work, but adding `--password my_password` does
[21:47:10] <cybertoast> i instead just get … assertion: 18 { code: 18, ok: 0.0, errmsg: "auth fails" }
[21:57:21] <gregie156> anyone know how i can use $where from php?
[22:37:35] <vaq> Hello, I have configured 3 servers in a replicaset, how do I protect myself if two of those machines are down? To my knowledge I cannot ellect a new primary if only one server is left?
[22:41:50] <dan__t> 'afternoon
[22:43:47] <dan__t> I'm trying to automagically set up replication, but I want to do so in a way that would allow for two of the three nodes to not be operating at the time that replication was initialized on node01. Can I do this?
[22:48:21] <dan__t> ah I had a typo.... needed something like cfg = { ...
[22:50:46] <dan__t> either way, my json file doesn't do what i expect it to. i wnated replica config there ready to go while two of my three nodes still have yet to come up
[22:54:43] <vaq> Hello, I have configured 3 servers in a replicaset, how do I protect myself if two of those machines are down? To my knowledge I cannot ellect a new primary if only one server is left?