PMXBOT Log file Viewer

Help | Karma | Search:

#mongodb logs for Wednesday the 8th of July, 2015

(Back to #mongodb overview) (Back to channel listing) (Animate logs)
[00:09:11] <jecran> Just want to make sure, i tried to set 'upsert' to true, and tried a few variations of this db.collection(collection).insertOne(doc, {upsert:true}, function(err) and cannot get an 'upsert' but duplicate errors. What am i doing wrong? (using node)
[01:10:22] <symbol> Alright...I'm still hung on on the proper use case for Mongodb. Research and stack overflow is telling me that the moment I start realizing I need joins then I need to go back to a RDBMS.
[01:11:03] <symbol> I've been watching a lot of the webinars on mongodb.com and they suggest to embed by default and then consider referencing...then they make referencing seem like it's no big deal.
[01:11:46] <symbol> I should embed by default...but if the data changes a lot they recommend referencing it. A lot of different opinions from the same source...or I'm just really confused :D
[01:13:25] <bros> Can somebody please help me with an aggregation over a collection with subdocuments?
[01:13:46] <symbol> I can give it a shot.
[01:15:05] <bros> Thank you very much.
[01:15:28] <bros> I have a collection (orders). The collection has documents. Each document has a subdocument called "log".
[01:15:44] <bros> I log what time a user starts and finishes an order (amongst other things).
[01:16:10] <bros> I'm trying to aggregate over all of the orders, but am having trouble aggregating. I'm aware on unwind, which helps me get one of the values out of log, but I do not know how to get the second.
[01:16:39] <bros> Once I unwind, the array is broken down in the pipeline. I've tried a combination of $project, $math, and $group pipelines to rebuild it with the array broken down into fields, but have had no luck.
[01:19:58] <bros> symbol: Is this not possible through aggregation?
[01:20:27] <symbol> Can you throw your code and an example doucment in a gist or something?
[01:23:00] <bros> symbol: https://gist.github.com/brandonros/d00d73f53589416b04e8
[01:23:55] <symbol> And I thought you were just a bro...nope that's your name.
[01:24:32] <bros> symbol: haha, sorry for the confusion.
[01:25:20] <symbol> So what are we trying to aggregate here?
[01:27:03] <bros> symbol: if (log[i]['action'] === 'opened') { started = log[i]['time']; } else if (log[i]['action'] === 'shipped') { ended = log[i]['time']; }
[01:27:42] <bros> I guess I could build an index if I really have to.
[01:27:47] <bros> That'd be smarter, no?
[01:28:30] <symbol> If you'll be doing the query a lot - I suppose a compound index would help...that won't fix your aggregation problem though.
[01:28:46] <bros> What will fix my aggregation problem?
[01:29:00] <symbol> heh, I still don't know what your aggregation problem is :)
[01:29:30] <symbol> Are not getting back the proper result?
[01:29:39] <bros> I don't know how to write the aggregation.
[01:29:42] <bros> I don't think it's possible.
[01:29:58] <bros> symbol: I have this https://gist.github.com/brandonros/3b65d4d6ba5765e26c80
[01:30:05] <bros> But I want to be able to calculate the start and end time of each document
[01:30:28] <symbol> Ah, ok
[01:30:48] <bros> Is it possible?
[01:31:52] <symbol> I believe so - I'm checking the docs out.
[01:35:25] <symbol> I think you could do $subtract with the values.
[01:35:40] <symbol> http://docs.mongodb.org/manual/reference/operator/aggregation/subtract/#exp._S_subtract
[01:35:56] <bros> I can't reference the values though, no?
[01:36:06] <bros> I can't use array indicies.
[01:36:42] <bros> '_id': '$log.0.time' yields Array[0]
[01:37:37] <symbol> Oh...why don't you just do it like this example? http://docs.mongodb.org/manual/reference/operator/aggregation/subtract/#subtract-two-dates
[01:37:52] <bros> That's when you have two fields.
[01:37:54] <bros> I have an array.
[01:38:02] <symbol> Ah, sorry.
[01:38:16] <bros> Any idea?
[01:39:53] <symbol> You might have to do something fancy with map/reduce unless someone else here knows the aggregation framework better (which is very, very likely)
[01:40:38] <bros> Is it bad schema?
[01:40:47] <bros> If the documents had fields "started" and "ended", I'd be in better shape, no?
[01:41:14] <symbol> I wouldn't call it bad just yet...sure that'd make it easier.
[01:41:21] <symbol> http://stackoverflow.com/questions/13708857/mongodb-aggregation-framework-nested-arrays-subtract-expression
[01:41:50] <symbol> That's a step closer.
[01:41:53] <bros> How can I cleverly do multiple unwinds?
[01:42:11] <bros> If I unwind $log to project opened, how can I re-unwind $log to project shipped?
[01:42:39] <symbol> Oh, I'm not suggesting muliple $unwind...I was mainly referring to the use of $project with $unwind and $subtract
[01:43:47] <bros> How can I $unwind and $project both values?
[01:43:54] <bros> Do you see my dilemma?
[01:43:59] <symbol> Yeah, I do
[01:45:10] <symbol> I wonder if there's some hidden $match magic
[01:46:10] <bros> I guess I could get really nasty. $match, $project log as log *and* some dummy field log2
[01:46:19] <bros> unwind log, match opened, project opened and log2
[01:46:24] <bros> unwind log2, match shipped, project all fields
[01:46:25] <bros> Yeah?
[01:46:30] <bros> Is that like, sin?
[01:46:38] <symbol> Lol
[01:46:41] <symbol> I think that's sinful.
[01:46:49] <symbol> I mean, I feel dirty and all.
[01:46:52] <bros> haha so do I
[01:47:00] <bros> Are there extreme advantages for using aggregations over regular finds + client logic?
[01:47:52] <symbol> I'm not really that sure...everything I read claims that the aggregation framework is the fast way to go.
[01:48:03] <symbol> But in reality, it's one db query and simple math on the application side.
[01:48:16] <preaction> it depends on where your bottleneck is
[01:48:54] <symbol> preaction: Have you been following? Really interested if this is something that can be done in the pipeline.
[01:48:57] <bros> Are subdocuments commonly used? All of my headaches Mongo come with my newbie decision to use them.
[01:49:21] <symbol> I'm still wrestling with the proper use case myself
[01:49:40] <preaction> i have no idea, i don't use it. it's always seemed kind of obtuse
[01:49:57] <symbol> Isn't the aggregation framework one of the "selling points"
[01:50:46] <Boomtime> bros: (sorry for arriving late) the SO question you linked is answered.. is there an updated question?
[01:51:22] <cheeser> bros: yes, they're quite common
[01:51:41] <symbol> They experts have arrived ;)
[01:52:21] <bros> cheeser: Do you have an answer to my aggregation subdocument problem or did I just construct bad schema?
[01:52:33] <cheeser> i don't
[01:53:24] <bros> Boomtime: do you have an answer?
[01:53:24] <symbol> Wouldn't map/reduce be a viable solution? More verbose but it'd be easier since you can work with the document and emit the proper values.
[01:54:26] <bros> I might be able to use $min $max.
[01:54:40] <symbol> I was just thinking that...along with $group?
[01:55:28] <bros> I doubt it though. To subtract with min and max? lol. asking a lot.
[01:56:00] <symbol> Hmm...$match for the proper status...sort by time...subtract?
[01:56:03] <bros> and that's invalid in an aggregation. cool.
[01:56:18] <bros> kind of disappointing.
[01:56:23] <bros> think it will come in a later version?
[01:57:15] <Boomtime> bros: if the SO question is a relevant summary of your current question, i will read it in a little while (am busy right now, but i will get to it)
[01:57:24] <bros> it's not.
[01:57:25] <bros> at all.
[01:57:31] <bros> it talks about multiple nested subdocuments
[01:57:44] <bros> I need to get fields out of a subdocument in an aggregation pipeline, but it's not possible.
[01:57:49] <symbol> Oh, check out the answer on this http://stackoverflow.com/questions/27473315/subtract-group-aggregate-values-in-mongodb
[01:58:03] <symbol> it groups on conditions then subtracts
[01:59:24] <symbol> You could $unwind, $group with $cond, $project, and finally $subtract
[01:59:42] <symbol> Throw in a $match at the beginning for good performance, eh?
[01:59:46] <bros> How would I group with cond?
[02:00:09] <bros> I guess I could go by _id
[02:00:15] <Boomtime> bros: your summary in words is trivial to achieve, clearly there is something particular about your data.. can you gist your troublesome document and what you've tried?
[02:00:19] <Boomtime> pastebin etc
[02:00:34] <bros> Boomtime: https://gist.github.com/brandonros/d00d73f53589416b04e8 https://gist.github.com/brandonros/3b65d4d6ba5765e26c80
[02:00:45] <bros> Try to get log.0.time and log.last_index.time in an aggregation pipeline
[02:00:54] <bros> Not trivial lol
[02:01:55] <symbol> $cond : [ { $eq : [ $status, "whatever"] }, 1, 0 ]
[02:02:53] <symbol> Oh, minus the 1, 0. Sorry.
[02:04:28] <symbol> Actually...I misunderstood $cond.
[02:04:49] <Boomtime> this still looks trivial, so clearly i'm not understanding.. you want to match on the first time entry in log array (log.0.time) but then retrieve the time field of the last entry in the log array for the matching document?
[02:05:35] <bros> Yes. if it makes it easier, the log array has a field called "action".
[02:05:40] <bros> opened and shipped are the two actions
[02:05:57] <Boomtime> seriously, is there anything else you need beyond my statement?
[02:05:58] <symbol> Wouldn't the non-trivial part be doing it all in the same aggregation?
[02:07:15] <Boomtime> my summary of the problem can be achieved in a single targeted query, aggregation is overkill: http://docs.mongodb.org/manual/reference/operator/projection/slice/
[02:07:57] <bros> It's obviously trivial to not use aggregation...
[02:11:56] <Boomtime> um.. i'm confused, are you attempting to use aggregation for something just for kicks? what is the reason for using aggregation if it's not necessary?
[02:14:42] <Boomtime> you can use aggregation for this if you like, but it'll be less efficient since there isn't anything to aggregate.. the solution i see, if you must is $match, $unwind, $sort on time (for assurance), $group with a $last, + $project somewhere if formatting is needed
[02:15:26] <acidjazz> mongochef is pretty sweet
[02:24:54] <symbol> Boomtime: Just because I'm interested in this...would it be more efficient to simply $slice than to do the subtraction between the two times with aggregation?
[02:25:07] <symbol> $slice and to the math application side.
[02:30:46] <Boomtime> as a general rule, any format or calculation that doesn't affect the result-set outcome is better off being done on the client - why add load to the server for something that could be distributed?
[02:31:04] <Boomtime> i.e if the amount of data being retrieved is unaffected, then it doesn't matter which end of the pipe you do it
[02:31:54] <Boomtime> you can do at the server where your server takes the capacity (that's great if it's 1975 and all your clients are thin terminals), or you can do the math at the client which is almost certainly free
[02:32:26] <symbol> That makes a lot of sense, thanks!
[02:32:30] <Boomtime> does the server care? no, but you might
[02:32:41] <Boomtime> cheers
[02:32:54] <symbol> So why are a lot of the webinars trying to swing the "real time analytics" with the aggregation framework as a selling point?
[02:33:10] <Boomtime> because that involves massive data reduction at the server
[02:33:26] <Boomtime> : -> "if the amount of data being retrieved is unaffected..."
[02:33:59] <symbol> Ah, gotcha.
[02:34:03] <Boomtime> analytics specifically avoids the data being returned - the server _aggregates_ the data set to a manageable report
[02:34:15] <Boomtime> and it's awesome at that
[02:34:29] <symbol> And it's faster to aggregate with mongo than send the million records over the wire?
[02:35:12] <Boomtime> definitely, sending the million records over the wire in that case has probably made the problem worse - the client still has to process it all, only now it isn't indexed
[02:36:15] <symbol> That makes sense...granted this is nothing new to the world of databases it seems. Aggregations have been around but I will say the aggregations in Mongo are easier to write.
[02:36:50] <Boomtime> they are definitely easier to debug.. since the pipeline can generally be viewed at any point to see if it contains what you expect
[02:37:21] <symbol> I've grown to really like the pipeline and how it works. It's very linear.
[02:45:06] <Boomtime> yes, many find it daunting / seemingly verbose to begin with - once you learn to manipulate them in the shell for dev work, eg. by using a var for each stage, it becomes ever more powerful
[02:49:17] <symbol> Something I'm still hung up on is determing the proper use case...a lot of the documentaion advises to embed by default then reference when things either grow or are large but rarely accessed. At the same time, I've been advised that if relationships start to emerge that Mongo isn't a good fit.
[02:50:04] <symbol> Relationships seem inevitable - especially when users are invovled.
[02:50:12] <symbol> Whew...can't type tonight.
[02:52:35] <Boomtime> one common mistake that people make is thinking that embedding versus linking is an exclusive choice
[02:52:43] <Boomtime> for example..
[02:53:01] <Boomtime> a comment with a reference to the 'user' that made the comment
[02:53:24] <Boomtime> why not link the user-id but also embed the username of the comment into the comment document (as it was when the user made the comment)?
[02:54:05] <symbol> Great example...since the username isn't likely to change very often.
[02:54:16] <Boomtime> this will avoid having to look up the username via the reference just to get the name of the user who made the comment.. meanwhile, it liikely provides all the information that was actually needed by having the reference
[02:54:36] <symbol> That makes sense.
[02:54:37] <Boomtime> but, oh no!, data is duplicated... but so what?
[02:54:43] <Boomtime> storage is cheap
[02:55:09] <Boomtime> and if you use wiredtiger with mongodb it might compress it out of existence anyway
[02:55:15] <symbol> Downside being maintenance?
[02:55:44] <Boomtime> maintenance is a funny thing.. when you sit down and look at how often metadata changes, a rounding error usually makes it zero
[02:55:57] <symbol> Yeah, good call.
[02:56:03] <symbol> Ok, what about a post with comments?
[02:56:16] <Boomtime> if you are super-keen to make sure the username stays up-to-date at all times then yes, you have some overhead to permitting users to change their name
[02:56:56] <Boomtime> here's a interesting thing about comments on blogposts etc.. how many times have you read past the first 5 or 10 comments?
[02:57:03] <symbol> Or more real-world, a product with reviews...we wouldn't want to pull 1000 reviews everytime we look a product.
[02:57:29] <symbol> Heh...that's a REALLY good point. Those first 5 could be embedded.
[02:58:13] <Boomtime> understanding your data well often solves the problem in ways you only have available when embedding is an option
[02:58:41] <Boomtime> and yes, you can stuff the overflow into another collection that you call on for those 1% of sticklers that are gonna read everything
[02:59:05] <Boomtime> optimize for the 99%, be able to handle the 1%
[02:59:17] <symbol> These could be proverbs
[03:00:37] <Boomtime> :D
[03:01:06] <symbol> Thanks!
[03:08:00] <markizano> How do you execute system commands in a mongo shell ?
[03:08:15] <cheeser> system commands?
[03:08:18] <markizano> like in mysql you can use "!cmd" to exec system commands outside the shell as the db user.
[03:08:23] <markizano> yeah\
[03:09:15] <markizano> to execute something outside db context.
[03:09:17] <cheeser> run(program[, args...]) spawn a program and wait for its completion
[03:09:29] <cheeser> in the shell: help admin
[03:11:10] <markizano> Thanks much, cheeser !
[03:11:23] <cheeser> np
[03:11:50] <markizano> wait, this runs on the client ??
[03:12:03] <markizano> oh .. i see ..
[04:04:55] <kba> I have a collection with a bunch of houses with a rent.
[04:05:14] <kba> When doing: `db.getCollection('houses').find({ rent : { $gt: 0 } });`, I only get one house, though, even though a lot match the criteria.
[04:05:19] <kba> What am I missing?
[04:05:54] <kba> Oh... It seems the rent is stored as a String, I just notice.
[04:06:05] <kba> Crap. I'm guessing that's the problem.
[04:23:34] <RegexNinja47> (Taconut) I'm having an emergency here: some of my users were saying they couldn't get into my program. I checked the database and half the users' database entries are just "_atomic". What do i do?
[04:24:56] <Boomtime> find the bug in your application?
[04:25:15] <RegexNinja47> Yeah and i fixed it
[04:25:22] <RegexNinja47> But
[04:25:37] <RegexNinja47> But i don't know what i did wrong
[04:26:15] <Boomtime> your last two statements are contradictory - how can you fix something if you didn't know what was wrong?
[04:26:37] <RegexNinja47> It was code to migrate my database to a new format
[04:26:44] <Boomtime> ok..
[04:27:12] <RegexNinja47> Now half the users are gone and half have been migrated
[04:27:40] <RegexNinja47> So i mean it works for the people who are still there
[04:28:05] <Boomtime> lucky them
[04:28:14] <RegexNinja47> Yeah :/
[04:28:37] <Boomtime> .. but you have a backup, right?
[04:28:53] <RegexNinja47> I thought i did
[04:29:13] <RegexNinja47> But evidently OpenShift (my hosting service) doesn't do backups
[04:29:15] <Boomtime> .. and of course, you were only deploying this untested migration script on a test QA copy of your live data, no harm done anyway, right?
[04:29:31] <RegexNinja47> I did apply it to my test server
[04:30:04] <RegexNinja47> And the three users i tested it on happened to work with the migration
[04:30:15] <Boomtime> i might recommend mms.mongodb.com for backups
[04:30:49] <RegexNinja47> Thanks.
[04:30:58] <RegexNinja47> But what does _atomic mean?
[04:31:23] <RegexNinja47> Its not a string, so does it hold some sort of data?
[04:31:35] <RegexNinja47> And if so, can said data be recovered?
[04:33:32] <RegexNinja47> Google doesn't pick up on underscores, so searching didnt help
[05:20:30] <Jonno_FTW> In pymongo, how do I get the updated object from update_one?
[06:08:05] <dimon222> you cannot
[06:08:13] <Jonno_FTW> lame
[06:08:24] <dimon222> update and insert methods dont retrieve object, they only retrieve result of process
[06:08:39] <dimon222> unless you meant something else?
[06:09:19] <dimon222> i'm not even sure that any kind of database retrieves affected objects on update methods oO
[06:09:30] <dimon222> like at all
[06:11:10] <dimon222> so i guess if u want to get result after update you need to do find and pick it :C
[06:11:20] <dimon222> object*
[07:46:42] <androidbruce> anyone using MMS monitoring agent/
[07:46:44] <androidbruce> ?
[07:46:52] <styles> nope
[07:54:25] <bogn> yes, but only for a little while so far
[07:55:16] <bogn> What's your question?
[08:01:46] <androidbruce> just some wonky issue with the mms agent
[08:01:57] <androidbruce> we've upgraded and all nodes are showing in mms
[08:02:03] <androidbruce> and metrics are there
[08:02:16] <androidbruce> but only one of the nodes in the repl set are "active"
[08:02:37] <androidbruce> the other says they are in standby
[08:06:01] <bogn> with "active" you mean is actively tracking new metrics
[08:07:04] <androidbruce> well in the agents tab under administration, the "state" is active or standby
[08:07:14] <androidbruce> but metrics are current for all nodes still
[08:07:30] <androidbruce> logs on standby nodes says " Nothing to do. Either the server detected the possibility of another monitoring agent running, or no Hosts are configured on the MMS group."
[08:38:50] <puppeh> is the bson_ext gem obsolete with bson version 3?
[08:39:06] <puppeh> I've noticed that bson_ext is only compatible with bson 1.x series
[08:43:05] <androidbruce> bogn: answered, https://docs.cloud.mongodb.com/faq/#do-i-need-a-monitoring-agent-for-every-mongodb-instance
[08:43:14] <androidbruce> only need one agent per mms group
[08:43:23] <androidbruce> the others are standbys in case of failure
[08:44:53] <bogn> yup, if you would've written "only one of the agents in the group are "active"" I could have answered right away
[08:45:16] <bogn> but with the words node and replica set I thought you were talking about actual mongod instances
[08:45:54] <bogn> So basically,yes. That's by design.
[09:02:51] <puppeh> I'm having problems with the mongo ruby driver version 2.0.6: http://pastie.org/private/20xubcr0oaacw3vclgkba
[09:02:55] <puppeh> is this normal? any ideas?
[09:03:13] <puppeh> I can't really use my terminal because of those log messages ^^
[09:36:29] <puppeh> hey, I can't change the database, anybody knows why?
[09:36:43] <puppeh> I'm doing a client.use(:foo) and then client.database still returns the previous database
[09:36:53] <puppeh> it only works if I pass :foo as an option when initializing the client
[09:36:54] <puppeh> (ruby)
[10:43:12] <puppeh> in mongo driver v2 (ruby) this command no longer exists: https://www.omniref.com/ruby/gems/mongo/1.8.5/symbols/Mongo::MongoClient/ping
[10:43:20] <puppeh> what is the alternative?
[11:01:13] <bogn> puppeh, regarding the logs, provide the constructor with {logger: logger_instance}
[11:02:34] <puppeh> thanks, found that
[11:03:04] <bogn> I'm switching databases with conn.db(db_name)
[11:03:10] <bogn> use sounds wrong to me
[11:03:56] <bogn> and the mongo v2 driver might be missing ping because it uses auto-discovery
[11:04:40] <bogn> Server Discovery and Monitoring (SDAM)
[11:04:47] <bogn> see https://www.mongodb.com/blog/post/announcing-ruby-driver-20-rewrite
[11:08:58] <bogn> and by the way: http://api.mongodb.org/ruby/1.12.2/Mongo/MongoClient.html#ping-instance_method
[11:09:14] <bogn> ah sorry, that was too early
[11:09:28] <puppeh> another question: :)
[11:10:05] <bogn> I confused the 1.12 and 2.0 API
[11:14:38] <bogn> you're of course free to ask another question
[11:16:36] <puppeh> http://pastie.org/private/0y5nup19faecffg6fwy9hq
[11:22:54] <bogn> you have a different handling of collections in your old code
[11:23:20] <bogn> is it possible that you were switching to different collections based on history
[11:23:50] <bogn> and the new code only works on one collection and thus you get the duplicate _id
[11:24:15] <bogn> but on the other hand upsert should handle that, I'd say it is not being reflected
[11:28:15] <bogn> hm, can't see anything else but the different collection handling you have there now
[11:34:20] <puppeh> oops sorry about the paste, nop collection is the same
[11:34:40] <puppeh> I think it tries to create another document with the same _id
[11:34:59] <puppeh> (coz of upsert)
[11:35:19] <bogn> upsert is made for that, if you find it, update it
[11:35:38] <puppeh> oh
[11:35:49] <bogn> if not, create it
[11:36:33] <puppeh> ok in my 2nd example, I see that the find() brings 0 results
[11:39:29] <puppeh> this is the correct pastie: http://pastie.org/private/m5mbw69jidngdx4hegxi4a
[11:43:42] <puppeh> hm, I think that the logic of this query is wrong. It says: "if you don't find a document with this _id and these conditions, then create it". It doesn't find it and then it tries to create it, with the same _id
[11:43:47] <puppeh> isn't that wrong?
[11:44:27] <bogn> but it should actually find it on the second run
[11:46:04] <puppeh> yes but aren't the conditions in the first `find` call wrong?
[11:46:09] <puppeh> I mean, they shouldn't exist at all, should they?
[11:46:24] <puppeh> since no documents with the same _id can exist
[11:47:16] <bogn> of course, but then upsert kicks in takes all query conditions and update operations and inserts that
[11:47:57] <bogn> http://docs.mongodb.org/manual/reference/method/db.collection.update/#upsert-parameter
[11:49:59] <bogn> is there any parallelism in your case
[11:50:09] <bogn> If all update() operations complete the query portion before any client successfully inserts data, and there is no unique index on the name field, then each update operation may result in an insert.
[12:36:50] <deathanchor> Is there any performance gain for bulk inserts aside from network performance?
[12:40:13] <bogn> yes, index runs
[12:42:21] <puppeh> bogn: no parallelism
[12:46:49] <leporello> Hi! How to find field with maximum value?
[12:47:11] <leporello> not filed itself, only the value.
[12:48:34] <cheeser> sort(that field).limit(1)
[12:51:11] <bogn> deathanchor however I just read that on stackoverflow
[12:52:24] <deathanchor> well would a bulk insert block until all are done?
[12:54:15] <cheeser> depending on the driver
[12:54:35] <cheeser> there are async variants with the java driver that'd probably provide a nonblocking bulk write
[13:06:20] <puppeh> (ruby client) hey, how can I close a connection if I have the Client object?
[13:12:57] <puppeh> in 1.8 we could do client.close
[13:27:32] <leporello> Still not like mongoose?
[13:27:58] <leporello> I have an error: exception: the group aggregate field \'reference\' must be defined as an expression inside an object
[13:28:03] <leporello> In quite simple query
[13:28:20] <leporello> var query = Layout.find({reference: {$exists: true}});
[13:34:18] <leporello> What could be simple? And why it tries to aggregate?
[13:50:01] <symbol> Is it a bad idea to store prices in MongoDB like 15.99?
[13:51:34] <StephenLynx> not at all.
[13:51:50] <symbol> That's nifty.
[13:51:57] <StephenLynx> unless you want extreme precision for financial operations, thats just fine.
[13:52:08] <symbol> No extreme precision here :D
[13:52:16] <cheeser> barring the usual caveats of storing currency values in double precision data types
[13:53:27] <symbol> I'm not sure I'm familiar with those caveats but I suppose that's something I can google for.
[13:57:40] <gabrielsch> hi, I need to make a little migration on my collection, my document property usar a "field: object", now I need to update all to field: [ { object } ], how can I do that?
[13:58:50] <cheeser> you'll have to loop over the docs, update, then write them back
[13:59:08] <gabrielsch> cheeser: should I create a ".js" script to that?
[13:59:38] <cheeser> that's one choice
[14:01:07] <gabrielsch> cheeser: sorry, I'm kinda lost to do this, should I loop with "db.Foo.find().forEach" ?
[14:04:47] <cheeser> gabrielsch: yes
[14:10:29] <gabrielsch> cheeser: did it! :) https://gist.github.com/gabrielsch/7cd963fe96c7e375e9f2
[14:14:43] <cheeser> awesome. nicely done.
[14:17:09] <dbclk> are you the same cheeser from ##java
[14:17:12] <dbclk> ?
[14:17:21] <cheeser> there can be only one
[14:17:29] <dbclk> :)
[14:17:58] <adsf> is it possible to use Calendar with mongo 3 in java instead of Date?
[14:20:06] <thikonom> Hi i will attempt to create a replica set. My set is as follows: I have an existing node with 50gb of data. Does anybody know if the database will be accessible when the data will be replicated to the newly added node ?
[14:21:05] <cheeser> the primary will, yes.
[14:22:11] <thikonom> thanks cheeser
[14:25:21] <thikonom> cheeser, I just found that: http://docs.mongodb.org/manual/tutorial/deploy-replica-set/#add-the-remaining-members-to-the-replica-set. At then of the paragraph it says "When complete, you have a fully functional replica set. The new replica set will elect a primary.".What is the newly added node is elected as primary ? Then its data wont be in a consistent state which makes the db inaccessible ?
[14:28:06] <cheeser> hrm?
[14:30:39] <fxmulder> is there a way to speed up rsync if the two replicas are mostly in sync? rsync seems to be writing over existing files
[14:31:42] <fxmulder> maybe modification time differences
[14:31:46] <thikonom> cheeser [15:18] <@cheeser> the primary will, yes. (Was that going to me or to someone else ?).
[14:36:36] <cheeser> to you, thikonom
[14:39:16] <fxmulder> should the file content between replicas be exactly the same?
[14:40:13] <fxmulder> I'm wondering if I use --checksum with rsync if it would speed things up
[14:42:40] <cheeser> http://docs.mongodb.org/manual/tutorial/resync-replica-set-member/#replica-set-resync-by-copying
[14:44:39] <fxmulder> I don't see anything in there that answers my question
[14:45:51] <fxmulder> I'm curious if it is worth it to use the --checksum flag when rsyncing
[14:46:21] <fxmulder> if the timestamps are off but the file content is exactly the same, then I can save a network copy and a disk write
[14:46:39] <fxmulder> but if the file content isn't exactly the same then I am just adding a second read operation for each file
[14:47:28] <MatheusOl> ~.
[14:47:47] <MatheusOl> Sorry about that, SSH got stuck...
[14:48:08] <kali> fxmulder: no, the data will be layout in vastly different ways
[14:49:04] <fxmulder> well thats unfortunate
[14:49:07] <thikonom> cheeser. Thanks, regarding the link I sent before, I am just trying to clarify what "When complete, you have a fully functional replica set. The new replica set will elect a primary." means. I am wondering what happens when the newly added node is elected as primary. If the data has not been replicated to it from the original node then the database wont be accessible ?
[14:50:27] <cheeser> during the election process, you can't write, no. if you have secondary reads enabled you can read, though.
[14:55:15] <puppeh> I can connect to a single instance using the ruby mongo client but when I enter 2 servers I get a connection refused (2)
[14:58:21] <puppeh> can it be because I run the 2 instances on the same host?
[14:59:20] <cheeser> 2 instances of the client? or the server?
[15:00:54] <kas84> Hi
[15:01:28] <puppeh> cheeser: of the server
[15:01:37] <puppeh> cheeser: the client is also on the same host, but 1 instance
[15:01:46] <kas84> when doing update with upsert =true the node.js mongo driver is not returning the _id of the inserted documents
[15:01:52] <kas84> any idea?
[15:02:06] <cheeser> you can run as many instances of the server as you want on a machine provided they use different ports and data dirs
[15:02:08] <puppeh> actually I'm using the very same example from http://docs.mongodb.org/ecosystem/tutorial/ruby-driver-tutorial/#creating-a-client
[15:02:16] <puppeh> they do use different data dirs and ports
[15:02:42] <cheeser> try connecting via the shell. then try with the ruby client.
[15:02:51] <cheeser> you probably have a bug in your ruby code.
[15:03:49] <puppeh> via shell is fine
[15:04:53] <cheeser> there you go
[15:12:03] <thikonom> cheeser: Thanks, its a bit complicated cause then i have to switch off the secondary reads. Is there a way to explicitly specify the primary ?
[15:13:43] <deathanchor> is there another command besides .stats() for getting info on a collections' settings?
[15:17:34] <cheeser> thikonom: the primary is selected from amongst the repl set members. you can't really force it other than setting priorities on the secondaries and that has its own set of issues
[15:25:43] <thikonom> cheeser: thanks a lot.
[15:31:58] <cheeser> thikonom: np
[15:35:51] <puppeh> cheeser: this is what I'm doing exactly http://pastie.org/private/xiijnlkfyucqoumuzdzxq
[15:36:32] <puppeh> in my server logs I see that the client *does* connect when initialized
[15:39:20] <joannac> puppeh: and one of those 2 is the primary?
[15:39:33] <puppeh> no idea :P, how can I set/check this?
[15:39:44] <puppeh> I'm just following the tutorial: http://docs.mongodb.org/ecosystem/tutorial/ruby-driver-tutorial/#inserting
[15:39:49] <joannac> connect in the shell and run rs.status()
[15:40:20] <cheeser> yeah. looks like there's no primary
[15:41:20] <puppeh> { "ok" : 0, "errmsg" : "not running with --replSet" }
[15:41:41] <puppeh> ok I must pass the argument --replSet to the server I suppose
[15:43:40] <cheeser> yes. for each member of the replset
[15:43:57] <EXetoC> any idea why it sometimes is {ok: 1.0} rather than {ok: 1}?
[15:49:08] <RegexNinja47> So i managed to find a json string of my mongodb datavase! How can i use that to recover everything?
[16:14:16] <deathanchor> EXetoC: for same commands?
[16:19:31] <EXetoC> deathanchor: it might just be for ismaster for whatever reason
[17:11:04] <adsf> cheeser: are you around?
[17:42:43] <cheeser> adsf: yep
[17:43:15] <adsf> cheeser: may have answered it myself :p Was just wondering on a sensible pattern for the java driver
[17:43:54] <adsf> should i close connection after each use? atm i instantiate a class that connects and never really shut it down :p
[17:44:04] <adsf> until the job dies in quartz
[17:44:56] <cheeser> should you close what now?
[17:45:08] <cheeser> you're using the java driver, yes?
[17:45:11] <adsf> yes sir
[17:45:14] <adsf> like client.close()
[17:45:30] <cheeser> MongoClient maintains a connection pool so, no, you won't see those connections go away.
[17:45:32] <adsf> i find if i instantiate the class from other classes, if i close in one it seems to mess with the others
[17:45:37] <adsf> ok cool
[17:45:41] <adsf> thats what it seemed like
[17:45:52] <cheeser> whether you should close them manually depends on the lifecycle of your client
[17:46:05] <adsf> doesnt do a lot, i get some data, write some data
[17:46:13] <adsf> guess i should just close after im done writing
[17:46:28] <cheeser> does your quartz job create a new MongoClient each time?
[17:47:07] <adsf> yeah, i dont have any persistence in the jobs
[17:47:23] <cheeser> if the job creates the client, it should close it.
[17:47:29] <adsf> awesome, thank you :)
[17:47:37] <cheeser> unless that client is used elsewhere you should manage resources appropriately.
[17:47:56] <adsf> also, even if i instansiate the class multiple times
[17:48:06] <adsf> close will killl all connections?
[17:48:48] <adsf> reason i ask is i had odd issues where it would complain if i instantiated it in a method and closed it, but had it still open in another method where it was instansiated
[17:48:51] <adsf> if that makes sense
[17:49:34] <adsf> if so i can just make the close method static :p
[17:56:19] <cheeser> you can have multiple MongoClients if you need them. but usually you don't
[17:56:37] <adsf> will restructure my code
[17:56:52] <adsf> i create a connection from multiple methods in class
[17:56:58] <adsf> will just add a constructor and close it at the end
[18:11:48] <t-ready> trying to do an ubuntu (trusty) install. apt update fails - can't find multiverse/source/Sources. my sources.list.d file: deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.0 multiverse
[18:14:39] <t-ready> following instructions from here: http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/
[20:38:29] <mocx> anyone use mongooastic?
[20:38:49] <mocx> just curious if it's possible to dynamically set the elasticsearch type
[20:39:02] <mocx> something like: Model.plugin(mongoosastic, {type: this.type})
[20:39:59] <saml> hello how do I get production mongo data to local?
[20:40:13] <mocx> saml: mongodump
[20:40:27] <saml> would db.copyDatabase() bring production down?
[20:40:44] <saml> is mongodump safe? not taxing production servers?
[20:41:00] <mocx> bring your site down for a moment and do it
[20:41:05] <mocx> it shouldn't be taxing
[20:41:10] <mocx> there's also mongoexport
[20:43:20] <GothAlice> Ough. http://www.bbc.com/news/technology-33442419 < 17 year old, 50K hacks, MongoHQ included. (They use ColdFusion stuff? Huh.)
[20:44:19] <Zelest> That's awesome! :$
[20:44:59] <StephenLynx> "It also confiscated his PC and ordered him to handover €6,588 (£4,725) worth of property obtained through his crimes." wow, public enemy #1 :^)
[20:45:03] <mocx> hi Zelest
[20:45:24] <Zelest> heya, ltns!
[20:45:37] <StephenLynx> they shouldn't detain him for even those two years, seriously.
[20:45:59] <mocx> Zelest: no kidding, I don't hang out in the DO channel anymore so that's probably why
[20:46:20] <Zelest> mocx, yeh
[20:46:33] <Zelest> mocx, had my fair share of drama there, but i enjoy it :)
[20:46:48] <Zelest> here, GothAlice with kick me if I talk about the same stuff as in DO :P
[20:46:52] <mocx> haha, i left once they condemned the channel as unofficial
[20:47:28] <Zelest> official or not, I love the community.. we even have a tiny core channel now where people hang out :)
[20:47:53] <Zelest> btw, met one of the guys from DO in denmark 2 weeks ago
[20:48:00] <mocx> crazy
[22:00:18] <chrisinajar> Hi! I have a for loop and within it I call collection.update with some data. Only 1 update occurs, however if I run the exact same updates 1 at a time then all of them update. Update isn't returning errors, it just silently fails. What am i doing wrong?
[23:00:52] <Doyle> During an initial resync is it normal to have the optimeDate stay at 1970...?
[23:01:04] <Doyle> "optimeDate" : ISODate("1970-01-01T00:00:00Z"),
[23:03:15] <chrisinajar> Hi! I have a for loop and within it I call collection.update with some data. Only 1 update occurs, however if I run the exact same updates 1 at a time then all of them update. Update isn't returning errors, it just silently fails. What am i doing wrong? I tried passing in { w: 1 }, suggested from a stack overflow
[23:10:54] <dimon222> >however if I run the exact same updates 1 at a time then all of them update
[23:11:01] <dimon222> what do u mean all of them update
[23:11:11] <chrisinajar> well only 1 works otherwise
[23:11:19] <dimon222> so it only updates one record?
[23:11:27] <dimon222> in update method?
[23:11:34] <chrisinajar> i'm looping through all entires in a table, making an RPC to gather data, and storing that data in the model
[23:11:51] <chrisinajar> yes, despite calling update once for each entry, only 1 entry is edited
[23:12:20] <chrisinajar> if i copy the parameters logged out from the loop and paste that into mongo cli then it works
[23:12:23] <chrisinajar> for each one
[23:12:29] <chrisinajar> instead of just the 1 that works
[23:12:38] <dimon222> can u share code
[23:12:50] <dimon222> sounds really weird
[23:12:53] <EXetoC> åäö
[23:13:45] <dimon222> i was about to assume that update query once being called only updates one record - default for update parameter "multi" is false, which means only one document that fits requirements will be updates
[23:13:48] <dimon222> *updated
[23:14:06] <chrisinajar> yeah, i'm updating by _id 1 at a time
[23:14:16] <dimon222> but if you're calling it in for loop, it means its 100% supposed to update more than one document, weirdo
[23:14:34] <dimon222> need to see code, can u cut this small block and gist it or something
[23:14:48] <chrisinajar> looks like the first one always work and the rest silently fail and return success witn n: 0
[23:15:06] <dimon222> oh, but it didn't throw exception
[23:15:09] <chrisinajar> yeah, i'm shrinking the code, i have a lot of debugging crap in there right now
[23:15:14] <chrisinajar> no exceptions, no errors
[23:15:16] <chrisinajar> just doesn't update.
[23:15:17] <dimon222> probably there's no another element that fits your query requirements?
[23:15:25] <chrisinajar> ok: 1, n: 0
[23:15:31] <chrisinajar> that means it found 1 right?
[23:16:00] <EXetoC> is the batch size field just a driver thing?
[23:16:15] <chrisinajar> the first one returns { ok: 1, nModified: 0, n: 1 } and the ones after all return { ok: 1, nModified: 0, n: 0 }
[23:16:46] <dimon222> well, it means it passed successfully, but there's no element that follows requirement so nothing was updated after that
[23:17:00] <chrisinajar> maybe findOneAndUpdate will work, or whatever that method is called... i was trying to use mongoose with .save() but it had the same behaviour (only the first one works)
[23:17:01] <dimon222> what query do you use?
[23:17:30] <chrisinajar> { _id: doc._id }, where doc is a valid entry returned from mongoose
[23:17:59] <dimon222> but why do you put it in loop? do u have like list of ids?
[23:18:07] <EXetoC> the same part of the message header is used for the batch size and limit apparently. I dunno what's going on there
[23:18:09] <chrisinajar> i fetch all and do an operation on each
[23:18:16] <chrisinajar> it's a migration script to pull in data from another service
[23:18:27] <dimon222> probably it wasn't fetching anything other than this document then
[23:18:48] <chrisinajar> not according to console.log, as i said i debug the query and paste it into mongo cli
[23:18:55] <dimon222> try to print your document id before you execute update in your code inside of loop
[23:18:56] <chrisinajar> the _id is populated on all of them
[23:19:06] <chrisinajar> as is the value i'm trying to assign in
[23:19:46] <chrisinajar> i'm prooooobably going to switch to RethinkDB instead, just got the approval, but thanks for the debugging help!
[23:19:59] <dimon222> try to print id before executing update query inside of loop, so make sure you're processing different documents
[23:20:04] <chrisinajar> i did
[23:20:08] <chrisinajar> they're there
[23:20:12] <chrisinajar> and pasting into cli works
[23:20:16] <chrisinajar> only doesn't work from code
[23:20:33] <dimon222> share snippet with code, really strange
[23:27:41] <chrisinajar> dimon222: if your curious here's the code simplified a bunch, switching DB's though so I don't actually need any more help. Thanks!! http://pastebin.com/mFmSmLMc
[23:29:43] <dimon222> thanks
[23:39:35] <dimon222> weird