PMXBOT Log file Viewer

Help | Karma | Search:

#mongodb logs for Wednesday the 8th of May, 2013

(Back to #mongodb overview) (Back to channel listing) (Animate logs)
[01:59:34] <danlamanna> anyone have a clue why i get a syntax error on this? https://gist.github.com/danlamanna/5537650
[02:06:33] <lqez> danlamanna: Is ObjectId could be a l-value in expression?
[02:07:35] <lqez> looks weird to me
[02:08:32] <danlamanna> not sure what that means. I know its a bit weird because I want to use the object id as a key
[02:08:38] <danlamanna> using .toString also triggers the same error
[02:10:50] <lqez> danlamanna: http://stackoverflow.com/questions/4555228/mongodb-can-i-use-objectid-as-key FYI
[02:11:30] <lqez> danlamanna: did you try toString() ?
[02:12:05] <lqez> Or, why don't you just store '5183281c1ad940677c90f564' as string?
[02:14:33] <danlamanna> I can, but I assumed they were different
[04:17:41] <krz> since when did $unwind expect an array result?
[05:11:55] <krz> if i wanted to do an aggregation on comments: http://docs.mongodb.org/manual/core/aggregation/ instead of tags. how would i use $unwind here?
[06:19:12] <Garo_> Is it normal that the oplog is almost completely in res memory (ie. it's "hot") in a master of a replica set? I used mongomem to determine that currently around 95% of the oplog collection is mapped into physical memory.
[06:23:56] <krz> anyone: http://stackoverflow.com/questions/16418348/how-would-i-filter-out-sub-documents
[06:23:59] <krz> ?
[07:19:43] <pratz> hello guys
[07:20:42] <pratz> I am facing this problem http://dpaste.org/gyZZF/
[07:21:16] <Nodex> firewall?
[07:21:42] <Nodex> netstat -pan | grep 27017
[07:22:09] <pratz> Nodex: yes, i am behind firewall
[07:22:24] <pratz> Nodex: but mongodb used to work few days ago
[07:22:43] <Zelest> changed any hostname or so?
[07:22:46] <Nodex> netstat -pan | grep 27017
[07:23:03] <pratz> netstat -pan | grep 27017 returns nothing
[07:23:19] <Nodex> then mongo is not running
[07:23:27] <Nodex> check your error log
[07:23:59] <pratz> Nodex: here http://dpaste.org/EZWra/
[07:24:15] <Nodex> amazing, check your error log for the error
[07:27:18] <pratz> Nodex: here http://dpaste.org/qFVVj/
[07:27:23] <pratz> Nodex: todays logs
[07:28:05] <Nodex> 6250 Wed May 8 12:50:55.759 [initandlisten] exception in initAndListen: 12596 old lock file, terminating
[07:28:17] <Nodex> remove the lock file and restart it
[07:28:29] <[AD]Turbo> ciao all
[07:29:05] <pratz> Nodex: sorry, but how do i do that ?
[07:29:22] <Nodex> 6248 Please visit http://dochub.mongodb.org/core/repair for recovery instructions.
[07:29:29] <Nodex> it's all right there in the error log
[07:29:57] <Nodex> http://docs.mongodb.org/manual/tutorial/recover-data-following-unexpected-shutdown/#indications
[07:30:30] <oskie_> heh
[07:31:06] <pratz> Nodex: opps missed it
[07:34:16] <pratz> Nodex: thanks buddy , working correctly now
[09:38:24] <krz> how do i use $match with two conditions?
[09:40:24] <krz> nvm
[09:55:32] <Garo_> Here's a nice tip how to get quickly statistics about top collections which are queried with tcpdump: http://www.juhonkoti.net/2013/05/08/quick-way-to-analyze-mongodb-frequent-queries-with-tcpdump
[10:17:52] <Nodex> anyone using the 1.4.0beta2-dev php driver ? and is it stable?
[10:23:18] <kali> Garo_: mongodb comes with something called mongotop... from what i'm reading, it gives more or less the same information, without the impact of the promiscuous mode
[10:23:54] <Garo_> kali: that gives out the counts, not the amounts
[10:24:06] <kali> Garo_: ok
[10:30:47] <Nodex> Zelest : what driver version you running?
[10:32:34] <Zelest> Nodex, 1.3.4
[10:33:07] <Nodex> I wonder why the git driver after a git pull is a beta version... Derick ?
[10:33:22] <Derick> Nodex: master is the development branch
[10:33:28] <Nodex> ah, dang
[10:33:37] <Nodex> which is the stable branch
[10:33:39] <Derick> but please test it if you can!
[10:33:50] <Nodex> how stable is the dev branch?
[10:33:52] <Derick> you need the 1.3.7 release then
[10:34:03] <Derick> Nodex: well, we're hoping to do an RC very soon™
[10:34:07] <Derick> ie, in a day or two
[10:34:18] <Nodex> I don't mind testing if it's 95% stable
[10:34:28] <Derick> it's hopefully more like 99% stable :-)
[10:34:47] <Nodex> ah cool, I've put it on one server before I realised
[10:34:50] <Derick> it will deal a lot better when a replicaset isn't behaving as it should
[10:35:09] <Zelest> Derick, I noticed that if I have 3 nodes in a replicaset.. and one goes down and is listed as unhealthy/unavailable via rs.status(), the php-driver tries to connect to it anyway, waiting for the timeout to occur..
[10:35:11] <Nodex> is it mostly new features that would be unstable?
[10:35:17] <Zelest> Derick, is it supposed to be that way? o_O
[10:35:55] <Derick> Zelest: yeah... but that should be a lot better in 1.4 as well!
[10:36:04] <Derick> Nodex: there are almost no new features in 1.4
[10:36:17] <Derick> Zelest: 1.4 adds a blacklist for that
[10:36:37] <Nodex> what I'm trying to work out is.... if I upgrade will somehting that worked in an old version now be buggy
[10:36:44] <Zelest> but why do you want to connect to one of those?
[10:37:13] <Derick> Zelest: we need to connect to it in order to find out what is happening, but as I said, 1.4 has a lot better logic for avoiding that situation.
[10:37:31] <Zelest> well, if I have 10 web nodes, that aint going to help me much. :/
[10:37:40] <Derick> like I said: 1.4 :-)
[10:37:57] <Zelest> still 10 nodes I have to reconfigure each time a node goes down :P
[10:37:59] <Derick> Zelest: please try it if you can.
[10:38:12] <Zelest> should be an option to connect to unavailable nodes or not..
[10:38:23] <Derick> no, it shouldn't connect to them at all really...
[10:38:25] <Zelest> seeing the server still respect/care for the rs.status() map, right?
[10:38:33] <Zelest> mhm
[10:38:34] <Derick> rs.status might lie sometimes ;-)
[10:39:05] <Zelest> but if a master is available and you have readpreferences to read from the master only, ignore the slaves altogether :P
[10:39:34] <Derick> Zelest: yes
[10:39:43] <Zelest> it doesn't. :)
[10:39:59] <Derick> oh, well
[10:40:02] <Zelest> hehe
[10:40:04] <Derick> hmm
[10:40:11] <Zelest> seeing you connect first.. then set the read preferences
[10:40:21] <Derick> you can set connect = false
[10:40:35] <Zelest> oh
[10:40:46] <Derick> but we do need to do a discovery of the replicaset to even find out whether there are secondaries...
[10:40:50] <Derick> and to find out the master
[10:40:52] <Zelest> might goof around with this some in the next couple of days
[10:41:13] <Zelest> yeah
[10:41:56] <Zelest> i know it's tricky, but if you connect to let's say 3 nodes.. once it's connected to one node and the rs.status() is done, abort/cancel the other connects/discovery-probes.
[10:42:47] <Zelest> now i had 3 nodes, one secondary was down.. master was up and everything was working fine.. yet, the application was unavailable/unusable since it had to wait for the timeout to occur of the secondary that was down.
[10:43:08] <Zelest> which kind of defeat the whole point of using a replicaset as a sense of failover/redundancy :)
[10:45:31] <Derick> which is something 1.4 improves a lot!
[10:45:54] <Zelest> awesome :D
[10:46:07] <Zelest> not meant to complain or so..
[10:46:13] <Zelest> just wanted to let you know about my issue :)
[10:48:12] <Derick> you're not the only one :-)
[10:49:08] <Zelest> Hehe
[10:56:11] <Nodex> ok 1.4 installed - fingers crossed :D
[11:15:33] <krz> dumb question. how would one get all documents in a collection?
[11:15:44] <Zelest> db.collection.find()
[11:18:58] <krz> ty
[12:18:59] <yields> Having some problems planing a schema...
[12:24:21] <yields> basically there is "companies" collection, where each "user" can create multiple companies, each company has "customers", each "customer" has two properties "company_id" and "code" the "code" must be unique to each company.
[12:24:27] <yields> i hope someone understood :)
[12:24:33] <romenov> hi, I have a collections of lists, and I want to store settings of these lists in a different collection because there will be attributes that I really don't want in the lists collection. Can I use the _id of the list to create a document in the settings collection (so that they have the same ID over two different collections) or is that a nono?
[12:26:17] <kali> romenov: that's all right
[12:26:34] <romenov> aight tx kali
[12:27:30] <yields> should i just put the customers ids in a company document?
[12:29:02] <Nodex> yields : it really depends on your access pattersn
[12:29:05] <Nodex> patterns *
[12:30:19] <yields> I need to get the "company" and then the "customers" of those company, each "user" may have multiple companies, he basically picks which company to manage and then he sees it's customers.
[12:32:54] <yields> but i still need to query for specific customers of a company, for example i may want to look for a customer whose name is "david" within a "company".
[12:33:18] <yields> i guess this problem is relational, should i use relational database lol?
[12:47:07] <theRoUS> how can i tell if mongo is running with auth=true ?
[12:50:52] <theRoUS> it's set in the /etc/mongodb.conf file, but i don't see '--auth' on the command-line from ps -- and i can use a database and use 'db.system.users.find()' without authing first
[12:52:51] <joe_p> theRoUS: db.runCommand("getCmdLineOpts")
[12:55:16] <woozly> guys, why if I use DBOject (which returned from DBCursor.next()), why if I try to update this object like: myCollection.update(myDBObject, new BasicDBOject("$inc", new BasicDBOject("someField", 1))); - I can do it only once, on second, it will not increment field. Why??
[12:55:30] <woozly> (java)
[12:56:26] <theRoUS> joe_p: i'll try that in a sec
[12:59:42] <converser> Hi all. Quick question, what are the repercussions of using $ or . as keys in mongo. I ask because I've noticed something a bit unusual.
[13:00:00] <converser> Generally the mongo driver won't let you use $ or . in key names, but why is this exactly?
[13:00:34] <converser> EG {"$akey.." : "value" } would fail
[13:00:49] <Nodex> because they're reserved chars
[13:00:58] <Nodex> $ signifie
[13:01:12] <Nodex> signifies operators and "." moevs around paths
[13:02:00] <converser> Are they reserved by the ruby mongo driver or by mongodb itself?
[13:02:06] <converser> Stupid question.
[13:02:42] <converser> Alright well, decided to try out Mongoid (Using the moped driver) and it doesn't actually enforce this.
[13:02:58] <converser> So I can make something like this {"$$Option 1$.." : "$$Option 1$.." }
[13:03:06] <converser> Stores in mongoDB just fine..
[13:03:10] <converser> Any thoughts?
[13:07:24] <converser> I'm trying to guage risk. How dangerous is that?
[13:07:35] <converser> Even if its just a guestimate.
[13:10:34] <Nodex> bad idea
[13:10:57] <Nodex> when updating with the positional operator "$" you will run into all sorts of problems
[13:17:29] <converser> Crap. Guess its back to the drawing board with this one then.
[13:19:41] <Nodex> how come you used them in the first place?
[13:19:57] <converser> Wasn't my call.
[13:20:42] <converser> There is a structure in place in our app where the key is a button, and the value would be the number of clicks. EG {"button-1" => 5}
[13:21:27] <converser> But its actually a questionare builder. So anyone could type in anything. EG {"$20 Euros" => 5}
[13:21:40] <converser> Which would cause it to fail miserably.
[13:22:11] <Nodex> escape it lol
[13:22:12] <converser> Moped/Mongoid doesn't seem to care. But mongodb does.
[13:22:25] <Nodex> or just replace $ || .
[13:23:18] <kali> converser: it's cumbersome to have keys that are data and not application keywords... you'll run into all kind of problems
[13:23:20] <converser> Sorry, not sure what you mean by "escape it"
[13:23:32] <converser> @kali Tell me about it...
[13:23:34] <kali> converser: try {name:"button-1", value:5}
[13:24:11] <Nodex> or replace $ with :DLR: and "." with :DOT: or somehting
[13:24:52] <kali> Nodex: yeah, but but then comes the indexing problem
[13:25:38] <converser> Nodex: You're talking about sanitizing the characters as they go in and out of the database. Are those special characters or would I need to read serialize them in and out at application level.
[13:25:57] <Nodex> in and out
[13:26:12] <Nodex> this is only a hack , you're better off not using them period
[13:26:29] <Nodex> but if it's tightly nested in your app already then a hack is what you must do sometimes
[13:26:39] <converser> kali: You're structure above is perfect but its not going to work right now. Changing the structure like that isn't really an option
[13:26:55] <converser> Too nested
[13:27:00] <converser> Nodex: Story of my life....
[13:27:35] <converser> kali: Could you explain the 'indexing problem' a bit?
[13:28:17] <kali> converser: well, if you want to look for all {button-1 : 5}, you will want an index of button-1
[13:28:32] <kali> converser: if yo have dozens of "keys" you'll need as many indexes
[13:28:53] <converser> Ah, I understand what you mean now.
[13:29:24] <converser> Thankfully thats not going to be an issue though as there are no circumstances where we need to use button-1 or anything similar as an index.
[13:30:11] <converser> So it would be possible to use what Nodex mentioned as a solution. (:DLR: :DOT:)
[13:30:19] <converser> Possible, not ideal...
[13:31:14] <converser> Sanitizing the data as it goes in and out of the database seems the only option for now. Until we can get a better hash structure in place.
[13:31:20] <coin3d> hello. i have a collection "lecture_types" which stores documents with only one attribute: "name", which is a simple string. so i guess it doesn' make sense to reference to these documents. should i denormalize my other collections to store the name of a lecture_type directly? if so, would it be better to store the lecture_type_id as well?
[13:31:35] <kali> converser: well, you're the one who's gonna lie with it :)
[13:31:38] <kali> live
[13:33:36] <converser> kali: Don't misunderstand, changing the hash is definitely the right way to go. The only reason it cant work is because there is a mobile element involved. Meaning there are a ton of mobile apps in the wild which would break if they received that new structure before they could be upgraded
[13:34:04] <kali> coin3d: once again, it depends on the access pattern. but in that case it does not sounds like you're gonna alter these lecture_types anytime soon. so embedding seems to make sense
[13:35:01] <coin3d> kali: yup, okay. my access pattern is: i also need to have access to "all lecture types". so should i additionaly store a lecture_types collection with a unique name?
[13:36:21] <kali> coin3d: mmmm i'm not sure hos "distinct" is optimized since 2.4: maybe running a distinct will only access the index (assuming there is on on the lecture_type field of the lecture collection)
[13:37:36] <kali> converser: try to get the app developers to get a "force update now" feature in the protocol. it only took me three years to get them to do it for our apps :)
[13:38:23] <kali> converser: so i still have three years worth of hacks and cludge to deals with the version we can not force update, but at least we are not adding un-removable cludges anymore
[13:42:16] <converser> kali: Good point. Think I'll have a word with the CTO about it.
[13:42:41] <converser> kali: Just one last question. Nodex mentioned escaping the keys earlier on. Did he mean like strings?
[13:43:06] <converser> kali: Would something like {"/$akey" => "avalue"} actually work?
[13:44:09] <kali> ha no. you need a different kind of escaping. backslash will not work. what Nodex suggests is "$akey" -> ":DLR:akey"
[13:44:22] <converser> Ah ok.
[13:44:28] <converser> Too much to hope for I guess.
[13:44:37] <kali> we have a case like this, we're using "€akey"
[13:46:02] <converser> I see. So when you read whatever object that belongs to, your turning '€a' into a '$' or some other character. Right?
[13:46:50] <kali> € into $, yes. that direction in the less profitable
[13:58:19] <converser> kali: I get why the less profitable way bugs you bug I'm kind of stuck. If I was to change the structure of the model in the way you suggested then everything in the wild would break. We cant really afford to take that knock on the chin.
[13:58:30] <zokko> hello
[13:58:53] <zokko> is it safe to HUP mongodb? i need to reload config, verbose logging was turned on :-)
[13:59:49] <kali> zokko: i'm not sure it reloads the config. i think it will only cycle its file descriptors on log files
[14:00:39] <kali> zokko: mmmmm USR1 for log rotating actually. so i don't know what a HUP does :)
[14:00:45] <zokko> kali: really? HUP commonly should reload config.:/
[14:03:13] <converser> If using $ is so destructive to the mongoid database, What do you think about Mongoid letting something like that through? Isn't that kind of important?
[14:03:37] <converser> Potentially a bug report for Durran?
[14:06:31] <coin3d> kali: does a distinct-call cost much performance?
[14:11:33] <Nodex> why dont you just store the thigns you need in distinct in a separate array somewhere in another collection and $addToSet if you ever add a new one?
[14:14:38] <kali> coin3d: http://docs.mongodb.org/manual/reference/command/distinct/ the last line says it will use the index if there is one
[14:29:39] <failshell> hello. does anyone know of a cluster backup tool? something that can orchestrate the stopping of the balancer, locking a config + N nodes to then create a LVM snapshot?
[14:37:29] <starfly> failshell: I think most folks just develop their own scripts for that
[14:38:02] <failshell> that's what i thought. meh was worth asking before i start coding :)
[14:40:42] <ehershey> there's also a new backup service
[14:40:58] <failshell> ehershey: please enlighten me
[14:41:17] <ehershey> http://mms.10gen.com/backup
[14:41:51] <ehershey> it's a (primarily) hosted service from 10gen
[14:41:52] <ehershey> super new
[14:42:30] <failshell> yeah im not sure my bosses will like that idea
[14:55:10] <starfly> There was some talk of 10gen offering MMS for in-house installations, but I'm not sure where that went
[15:15:53] <Nodex> I've decided it's really stupid to -have- to put in delays in code to show that something has happened due to the speed of an app being so fast that it appears as if nothing happened :/
[15:17:55] <kali> Nodex: yeah, next time just put the sleep() directly, don't bother with the rest
[15:22:43] <Nodex> rather not tie up my backend so I put it in the front end
[15:29:22] <kali> yes. save the roundtrip
[15:29:49] <kali> save the white bears
[15:33:40] <Nodex> very annoying to have to put a setTimeout() though :/
[16:10:05] <yields> How can i reach Model static functions through, schema middleware ?
[16:19:54] <Nodex> eh?
[16:21:17] <yields> In a pre('save') middleware i would like to run a query, is it possible?
[16:21:39] <Nodex> I don't know what that means sorry
[16:21:54] <Nodex> it appears to be appside problems
[16:23:07] <yields> Nodex, how so ?
[16:23:32] <Nodex> becuase mongodb doesn't deal with middleware or models
[16:23:45] <Nodex> ergo it cannot be a server (db side) problem
[16:23:55] <Nodex> because *
[16:45:41] <Nodex> quick Q. ... if you guys could pick from scratch ONE transactional DB (for transactions only) to compliement MongoDB which would it be?
[16:47:34] <starfly> Nodex: MySQL if you're LAMP-oriented or Oracle if you're not LAMP-oriented and have buckets of money
[16:48:19] <Nodex> not lamp oriented and dont have buckets of money
[16:48:26] <kali> Nodex: postgresql :)
[16:48:47] <Nodex> kali : is it not a bit bloated just for transactions
[16:48:57] <Nodex> (that's a question btw LOL)
[16:49:09] <kali> Nodex: not more bloated than oracle :)
[16:49:25] <starfly> LOL, nothing is more bloated than Oracle
[16:49:29] <kali> mysql is a valid choice too, actually
[16:49:33] <Nodex> I was debating building somehting of my own just for the transaction part
[16:49:56] <Nodex> putting things into a queue and updating Mongo when the queue has ran (i/e transaction complete)
[16:49:58] <kali> starfly: EJB maybe. ho wait, that's part of oracle now too
[16:50:28] <kali> Nodex: i do transaction in mongodb all the time
[16:50:35] <Nodex> safe enough?
[16:50:48] <Nodex> for financial stuff I mean
[16:50:53] <kali> i make them safe
[16:51:03] <Nodex> (taking from one account and putting in another por example)
[16:51:03] <kali> two phase commit and all
[16:51:36] <starfly> I'd go with MySQL w/Innodb storage engine
[16:51:57] <Nodex> I don't want to add a load of bloat for what amounts to 0.5% of my stack
[16:52:03] <kali> yeah. innodb is a perfectly valid choice
[16:52:33] <Nodex> mebbe I'll check out that toruktu or w/e it's called
[16:52:41] <Nodex> tokutek *
[16:52:52] <starfly> Nodex: We're just saying… If you want no bloat, roll your own, but that's usually not in the best long-term interest
[16:53:37] <Nodex> probably is for me
[16:53:49] <Nodex> (in my interest)
[16:54:40] <starfly> Nodex: Cool, whatever, but if you want ACID out of the box, MySQL should be fine
[16:54:41] <kali> Nodex: imho, the biggest issue with mysql is HA
[16:55:30] <Nodex> starfly : Mysql = bloat for no reason
[16:55:37] <Nodex> kali : HA?
[16:55:44] <kali> high availibility
[16:56:00] <modcure> kali, then use mysql cluster :)
[16:56:10] <Nodex> so I would be better just making it happen in a queue or something
[16:56:11] <starfly> Nodex: No prob, sounds like you're headed in the direction you want
[16:56:17] <kali> modcure: i use rds, and i'm fading mysql out anyway
[16:56:21] <Nodex> starfly : I generaly am :)
[16:56:26] <kali> well, i've been fading it out for three years
[16:56:28] <modcure> rds?
[16:56:40] <kali> modcure: AWS managed mysql offering
[16:57:56] <kali> 17 tables remaining, i think
[16:58:40] <Nodex> I recently had to fix a freinds mysql based site... I have not touched SQL in ~3 years - I was lost for a day LOL
[17:02:12] <leifw> Nodex: you can email us at support at tokutek dot com, or come to the #tokutek channel, we'd love to tell you more about what we're doing with transactions in mongo if you're curious
[18:06:31] <richcollins> Can you issue multiple statements in one request?
[18:11:36] <Nodex> can you be a little more definitive ?
[18:24:20] <leostera2112> Has anybody knowledge of a entry-level to good read on performing ACID-like transactions with Mongo?
[18:25:16] <leifw> leostera2112: I'm working on adding native multi-statement transactions at tokutek
[18:25:58] <leifw> leostera2112: if you'd like to try it let me know, we have a prototype that we're hoping to have people try and give us feedback on
[18:26:04] <leostera2112> leifw: interesting, do you have any pointers?
[18:26:06] <TommyCox> richcollins: Comparable to MySQL, you can string together multiple statements in a single query, such as FINDing all documents WHERE the title equals foo, SORT by bar, then LIMIT to 100 records would be a psuedo example
[18:26:08] <leostera2112> leifw: I'd love to
[18:26:21] <leifw> leostera2112: http://www.tokutek.com/2013/04/mongodb-multi-statement-transactions-yes-we-can/
[18:26:36] <leifw> leostera2112: you can email us and we'll get you a version to try
[18:28:40] <TommyCox> Ah, I feel like I missed the mark on what was meant by multi-statement.
[18:32:46] <starfly> leifw: How do you ensure atomicity across multiple statements like updates? What about the cooperative, multi-processing that MongoDB does (writes yielding to reads)?
[18:33:44] <leifw> starfly: we're replacing the storage code with a fully transactional, concurrent engine that uses MVCC, and row locks for serializable isolation, so we don't need yielding
[18:35:04] <starfly> liefw: So you're using MongoDB as a shell for your own storage engine, interesting, but how will you keep in lockstep with the evolution of MongoDB?
[18:37:15] <leifw> starfly: most of the mongodb ecosystem is pretty well abstracted from the storage code, I backported hashed shard keys to our 2.2 branch in a couple hours for example
[18:37:25] <leifw> starfly: but in general we'll just have to see how it goes
[18:42:21] <starfly> leifw: I don't know your other published products, but presume you took the same general tack with them as well. I'm all for extending products to fill feature gaps and wish you well.
[18:43:26] <leifw> starfly: our other product is a storage engine for mysql, the api layer there is a lot clearer and well tested so it's a fairly different strategy
[18:43:48] <leifw> starfly: but thanks :)
[20:13:04] <JoeyJoeJo> I'm trying to use $or in php, but it gives me this error - MongoCursorException: localhost:27017: invalid operator: $or in MongoCursor->rewind()
[20:13:09] <JoeyJoeJo> Any ideas why?
[20:14:26] <starfly> JoeyJoJo: did you try the same command in the mongo shell to validate syntax?
[20:15:12] <scoutz> JoeyJoeJo: it should be a seperate array for each or element
[20:23:29] <scoutz> would it be ok to host my 3 config servers in different datacenters? (50-75ms between them)
[20:23:29] <fxhp> Hiya, I have an embeded array of objects, and I would like to sum a field 'tick'
[20:23:56] <fxhp> Should I post an example document?
[20:26:10] <starfly> scoutz: That should be OK, but do you have a large number of shards and lots of document migration activity between them? The 2-phase commit activity could be high if so.
[20:26:14] <fxhp> How would I sum the tick field?: http://pad.yohdah.com/111/f952e8d0-c797-47de-996b-33512e6db5bb
[20:28:34] <kali> fxhp: aggregation framework... but i think you'll want to denormalize it in the long term
[20:28:56] <scoutz> starfly: well i'm sharding a single collection of user sessions (shardkey: sessionid)
[20:29:34] <scoutz> i'm not really sure of migration activity tho, i haven't setup sharding yet i'm only using a replica set for now
[20:29:52] <fxhp> kali: I was looking at the aggregation framework, I couldnt get the syntax right, mind giving it a shot?
[20:30:19] <fxhp> kali: also you think denormalizing votes into its own collection is better?
[20:30:53] <kali> scoutz: it's one of the deployment scenarios in several presentation by 10gen people
[20:31:21] <kali> fxhp: show me where you stuck
[20:32:33] <kali> fxhp: not in its own collection, but having the sum of the votes as a field in the document can be very convenient
[20:33:00] <starfly> scoutz: I'd guess that sessionID are transitory and only persist for a particular Web app session during it's life. Unless you configure for many shards, I think you'll be OK. Nothing like a trial, though.
[20:37:05] <fxhp> kali: i see
[20:38:44] <scoutz> starfly: actually they are sessions but sessions for an adserver so maybe more like 'profiles', the session will stay in the collection for as long the cookie times out (1 year+), i have thought of different shard keys but since i will only need to get 1 object from the collection each time i thought the sessionid would be the best shard key
[20:42:10] <starfly> scoutz: are the shard keys hash-like or monotonically increasing? The latter, of course, should be avoided to cut down on document migration and bottlenecking on document creation writes.
[20:42:57] <kali> using the new hashing indexing/sharding can solve this
[20:43:19] <kali> but yeah, don't shard on a timestamp :)
[20:44:23] <starfly> kali: true enough, unless scoutz isn't at the release (2.4) where that's available
[20:47:04] <scoutz> i'm using db version v2.4.3
[20:47:38] <scoutz> starfly: they are hash like and not monotonically increasing
[20:51:00] <starfly> scoutz: good, but back to the earlier question, I personally wouldn't be too concerned about how much latency is involved in the config server updates unless you have a perfect storm of a lot of shards and a lot of document migrations between those shards (or a lot of splits inside shards, which also require config server updates). I think you need to dive in and try some sharded configurations.
[20:51:26] <fxhp> kali: are you sure an aggregate is needed
[20:52:14] <fxhp> I don't want to sum many objects, just all the votes.tick
[20:52:27] <fxhp> of a given document
[20:52:29] <scoutz> starfly: thanks :)
[20:53:02] <starfly> scoutz: NP, best of luck
[21:08:16] <fxhp> kali: db.posts.aggregate([{$group:{_id: "$user_id", ticks: {$sum: "$votes.tick"}}}])
[21:08:24] <fxhp> doesn't seem to work
[21:20:48] <TommyCox> fxhp: Try this db.posts.aggregate([ { $group: { _id: { "$user_id", ticks: {$sum: "$votes.tick" }} }} ])
[21:21:21] <TommyCox> Was missing a set of brackets after _id to signify an array
[21:24:12] <fxhp> TommyCox: that doesn't work either, I'm at a loss
[21:25:40] <fxhp> http://docs.mongodb.org/manual/reference/sql-aggregation-comparison/#examples
[21:25:53] <fxhp> How wold I sum the prices of the embeded items array
[21:26:09] <fxhp> (should return 2 given that example)
[21:30:42] <iwaffles> Is it possible to find an ID in an array that's in the document?
[21:30:58] <iwaffles> so if I have a document that has user_ids can I do a find that does if the user_id exists in user_ids[] ?
[21:31:19] <iwaffles> or maybe something like user_ids[] contains user_id?
[21:35:14] <scoutz> iwaffles: http://docs.mongodb.org/manual/reference/operator/in/#op._S_in ?
[21:35:30] <iwaffles> I think that's the reverse? Or maybe I'm being confused
[21:36:11] <iwaffles> I have an array in the document, and I want to pass in one value and check if that document contains it inside that array
[21:36:22] <iwaffles> It's probably less trivial than I'm making it out to be
[21:38:05] <TommyCox> fxhp almost got it, looks like you have to unwind on items
[21:38:29] <TommyCox> or votes in your case, to get each vote apart
[21:39:37] <TommyCox> db.posts.aggregate( [
[21:39:38] <TommyCox> { $unwind: "$votes" },
[21:39:39] <TommyCox> { $group: { _id: "$user_id",
[21:39:40] <TommyCox> ticks: { $sum: "$items.tick" } } }
[21:39:41] <TommyCox> ] )
[21:40:06] <TommyCox> db.posts.aggregate( [ { $unwind: "$votes" }, { $group: { _id: "$user_id", ticks: { $sum: "$items.tick" } } } ] )
[21:40:30] <TommyCox> If that doesn't do it, I'm stumped lol
[21:41:54] <iwaffles> huzzah, I got it :)
[21:42:47] <fxhp> TommyCox: So that sort of works, but it ends up querying all documents from the collection, unwinding the embedded votes object, and summing them all together
[21:42:59] <TommyCox> my bad
[21:43:00] <TommyCox> db.posts.aggregate( [ { $unwind: "$votes" }, { $group: { _id: "$user_id", ticks: { $sum: "$votes.tick" } } } ] )
[21:43:07] <TommyCox> that should work
[21:47:16] <TommyCox> Well, that'll give you a user id with the total number of ticks they have
[21:47:36] <fxhp> TommyCox: yeah, I'm so lost
[21:48:10] <TommyCox> fxhp: Did it not work? what's the output look like? What do you want it to look like?
[21:50:36] <freezey> in the pecl-mongo driver mongo.native_long => no value .. previously you were able to set this to false
[21:50:40] <freezey> however now it is looking for an int
[21:51:24] <freezey> anybody know why?
[21:53:29] <TommyCox> fxhp: maybe you'd like to count the ticks for a document instead of the user mentioned in the document. You'd use this instead:
[21:53:40] <TommyCox> db.posts.aggregate( [ { $unwind: "$votes" }, { $group: { _id: "$_id", ticks: { $sum: "$votes.tick" } } } ] )
[21:58:46] <TommyCox> fxhp: If you can provide some more information on what your end goal is, I can help you further, but for now I'm not entirely sure what you're trying to achieve. Cheers!
[22:05:18] <fxhp> TommyCox: for a given "post" object, I want to sum its votes.tick
[22:07:14] <TommyCox> fxhp: This should do it:
[22:07:15] <TommyCox> db.posts.aggregate( [ { $unwind: "$votes" }, { $group: { _id: "$_id", ticks: { $sum: "$votes.tick" } } } ] )
[22:08:29] <fxhp> TommyCox: that worked!
[22:08:45] <TommyCox> Lol, took me long enough
[22:09:20] <fxhp> TommyCox: with that said, I only need the work done on one post_id, so I'm going to try to add the $match
[22:10:28] <fxhp> TommyCox: woot!
[22:10:33] <TommyCox> db.posts.aggregate( [ { $unwind: "$votes" }, { $group: { _id: "$_id", ticks: { $sum: "$votes.tick" } } }, { $match: "YOUR_POST_ID"} ] )
[22:11:17] <meghan> hi everyone. anyone going to be at mongodb sf on friday?
[22:13:15] <TommyCox> fxhp: See post above for how to add $match
[22:13:32] <TommyCox> er, actually
[22:13:36] <TommyCox> matches should go first
[22:14:33] <fxhp> http://pad.yohdah.com/112/mongodb-aggregate-sum-an-embedded-object-field
[22:14:41] <fxhp> That worked
[22:15:09] <fxhp> I don't really understand the _id: "$_id" in the group
[22:15:19] <fxhp> but it works
[22:15:28] <TommyCox> db.posts.aggregate( [ { $match: { _id : "YOUR_POST_ID" } }, { $unwind: "$votes" }, { $group: { _id: "$_id", ticks: { $sum: "$votes.tick" } } } ] )
[22:15:46] <TommyCox> $_id is the unique id of the post.
[22:19:03] <TommyCox> oh, so group does it's grouping based on the keys in _id, so I'm grouping on the unique key $_id. You can group on multiple keys, but not needed in this case. It's really only needed to group back together the unwound votes in this case
[22:21:06] <TommyCox> But yay! Glad I could help.
[22:24:28] <fxhp> TommyCox: thanks, now that I have this monster of a query, I'm wondering if it would be better to just do that math from my programming lang
[22:25:52] <TommyCox> Lol, could be. The question is, with this awesome query doing for you, why would you want to reprogram the wheel?
[22:26:15] <TommyCox> fxhp
[22:27:15] <fxhp> TommyCox: I already query for the "post" object above in the code
[22:32:44] <TommyCox> fxhp: If you want to do it all in one query, you can use $project to get the other fields you need from the resulting aggregation document, no need to query it twice. But honestly, I imagine a foreach - or whatever your language uses - would probably be more readable than a complicated aggregation query. The aggregate framework might be a little overkill for your sitch
[22:33:18] <TommyCox> I just prefer to do it in the query for speed
[22:34:21] <fxhp> TommyCox: agreed: http://pad.yohdah.com/113/793818dd-68d7-4599-a7c5-6086d80831d2
[22:34:42] <fxhp> Do you use python TommyCox (pymongo?)
[22:37:26] <TommyCox> fxhp: Nah, I'm a PHP guy. I can read it though. That is tons simpler ;p
[23:24:47] <Baribal> Hi. How would you structure documents that represent coordinates in 64-dimensional space to find those that are within a certain euclidean distance of each other?
[23:58:29] <iwaffles> Is it possible to query for one thing then add another query onto it?
[23:58:45] <iwaffles> To simply add the documents from the second query to the first query?
[23:58:53] <iwaffles> Sort of like a join?
[23:59:08] <Baribal> iwaffles, you mean an $or query?