PMXBOT Log file Viewer

Help | Karma | Search:

#mongodb logs for Wednesday the 17th of August, 2016

(Back to #mongodb overview) (Back to channel listing) (Animate logs)
[04:18:47] <aonomus> Anyone up at this time of night? Possibly able to answer a question?
[04:27:56] <Boomtime> hi aonomus! nighttime is a geographical feature, people in this channel are all over the world -- ask your question, someone may be able to help :-)
[04:28:05] <aonomus> Fair enough
[04:28:30] <Boomtime> (btw, it's just after midday here)
[04:28:56] <aonomus> So I'm using node-red to write data to mongodb, the format going in is "date":"2016-08-17T02:15:13.000Z" however Mongo seems to want to use moment.js to interpret that date, and turn it into a nested json object
[04:29:40] <Boomtime> eh? mongodb does no interpretation, what is the type of the data going in?
[04:29:51] <Boomtime> what you quoted was a string
[04:30:10] <Boomtime> but if you're getting something else out, then it didn't go in as a string -- i suspect you have a Date object
[04:30:27] <aonomus> Hm, so maybe it's node-red-node-mongodb converting the date
[04:30:40] <aonomus> Apologies for the semi-spam incoming...?
[04:30:47] <aonomus> But it shows up when retrieved like so
[04:30:48] <aonomus> "date": { "_isAMomentObject": true, "_i": 1471400113000, "_isUTC": false, "_pf": { "empty": false, "unusedTokens": [], "unusedInput": [], "overflow": -2, "charsLeftOver": 0, "nullInput": false, "invalidMonth": null, "invalidFormat": false, "userInvalidated": false, "iso": false,
[04:30:51] <aonomus> (and it goes on)
[04:31:07] <Boomtime> try testing out your stuff in the mongo shell -- the shell is a javascript interpreter so it should be familiar quick enough
[04:31:28] <aonomus> This is where I invoke the 'dammit jim I'm a chemist, not a programmer'
[04:31:44] <aonomus> card and hope for sympathy. I've trawled google and docs for hours to no end
[04:32:05] <Boomtime> if you're not a programmer, but trying to do programmer stuff, you're going to have a frustrating time
[04:33:03] <aonomus> I do enough of it for mad science, I'm just entirely unfamiliar with js, node.js, mongodb; that's all an aside.
[04:33:08] <Boomtime> btw, the big splat of stuff you pasted is JSON
[04:33:43] <Boomtime> that JSON is not even remotely related to MongoDB, nor to the MongoDB Node driver, it is thoroughly user-land data
[04:34:03] <Boomtime> it kind of looks like some custom date object from some abstraction layer
[04:34:14] <aonomus> Fair enough - that sanity checks that it's what is being fed into mongo, not what's coming out of it
[04:34:27] <aonomus> At least now I know to look in a different direction, thanks!
[04:35:28] <Boomtime> if you give the node driver an object that mongodb doesn't know, it'll just encode the raw document structrure as is, as json -- that object of yours genuinely looks like that under the bonnet
[04:36:15] <Boomtime> if you expected something else then it's because the object you have is generated by (and abstracted by) your framework
[04:37:57] <aonomus> I wasn't expecting the mongodb node to be converting the date format, I used to stuff the data into a text file which had the original date format. Oddly enough if I search that particular github repo for anything related I come up empty so far...
[04:38:05] <aonomus> (will keep digging, not looking for a handout answer per-se)
[06:30:52] <shackra> getting a configuration value from the mongo database is bad idea? because I have a code that do good amount of reads into the database and I'm worried in production this will slowdown my bot
[06:33:21] <Boomtime> @shackra: huh?
[06:33:31] <shackra> humm...
[06:33:37] <Boomtime> can you frame the question in terms of the how you intend to use mongodb?
[06:33:54] <shackra> Ok... I want to store the language preference of my users in the database
[06:34:23] <shackra> and retrieve it every time my app needs to send a translated message to the user
[06:35:25] <Boomtime> i think those are the other way around -- when you are about to send a message, you retrieve the setting to know if you need to translate it, yes?
[06:35:53] <shackra> yes, exactly
[06:35:56] <Boomtime> anyway, the only questions that matter are frequency and latency
[06:36:24] <Boomtime> but how did you know the message was for one of your users? is the user stored in the database?
[06:36:32] <shackra> yes
[06:36:42] <Boomtime> then you must have checked for the user right?
[06:36:48] <shackra> yes
[06:37:03] <Boomtime> can't these two things be combined?
[06:37:11] <shackra> sadly, no
[06:37:30] <Boomtime> why not?
[06:37:59] <shackra> because the way I built my app
[06:38:17] <shackra> well, actually
[06:39:07] <shackra> for some steps, between getting user's command and outputting a reply, there are a couple of reads on the database
[06:39:23] <shackra> 2, basically
[06:40:08] <shackra> the second read is actually many reads to the database since gathering the language preference for translating each string that's going to be send to the user as reply
[06:40:46] <Boomtime> the user has multiple language preferences?
[06:40:53] <shackra> no, just one
[06:41:13] <shackra> but he can switch the language later in the configuration options
[06:41:45] <shackra> my app is a Telegram Messenger bot, so, it serves to a lot of users
[06:42:40] <Boomtime> well, this is your call -- a query is fast, especially if it's well targeted, but there should be a good reason to do it
[06:43:10] <Boomtime> your application design currently forces you to do a superfluous extra query for the language preference, despite already having checked the same data recently
[06:43:22] <shackra> hmmm... yes.
[06:43:34] <shackra> I have this gut feeling of inserting Redis into the mix
[06:43:37] <Boomtime> you can either re-design that bit so you can avoid that extra query, or you can pay that small cost, at whatever scale it occurs
[06:43:48] <shackra> so it can work as cache for my mongo db
[06:44:16] <Boomtime> yes, a small design error can always be fixed by adding extra layers of complexity
[06:44:23] <shackra> lol
[06:44:37] <Boomtime> and extra layers that bring their own failure modes
[06:45:03] <Boomtime> simple systems have simple problems, complex systems have complex problems
[06:45:21] <shackra> well, I'm not sure what to do now...
[06:45:46] <Boomtime> the simplest solution for you is to make that extra query and observe, empirically, what the cost is
[06:46:03] <shackra> I can also make a global dictionary/hash and push that language preference there when it is first requested
[06:46:22] <shackra> well, that's a good course to take
[06:46:34] <shackra> but, I would have to simulate such load of users
[06:46:41] <Boomtime> you must have some state in which you can store this, otherwise you couldn't route messages correctly
[06:48:25] <shackra> thanks, Boomtime
[08:47:45] <ams__> Any pointers on what I might be doing wrong here greatly appreciated! https://groups.google.com/forum/#!topic/mongodb-user/NvYblQqTmE0
[08:49:51] <Derick> The initial sync started well but after 22gb (of 200gb) was synced it failed. Now when I resync (by doing cfg = rs.conf(), rs.reconfig(cfg) I get the following error in my secondary logs:
[08:49:56] <Derick> that's not how you resync
[08:50:07] <Derick> you should not need to mess with your replicaset config for this
[08:50:51] <Derick> but it's also not an error, just an informational message (category I)
[09:27:24] <ams__> @Derick Ah, but it is very much stopped
[09:27:40] <ams__> At 22gb it just sat there, never receiving more data
[09:30:29] <ams__> Which is why I did the reconfig(), which did seem to kick off a re-sync (but maybe I'm wrong)
[09:38:17] <ams__> Anyway, I've kicked it off a-fresh, I'll see how it goes this time and update
[09:38:26] <Derick> fingers crossed
[10:03:41] <ams__> https://www.irccloud.com/pastebin/iGKodbca/
[10:03:49] <ams__> @Derick It does say "initial sync done"
[10:04:07] <ams__> But .. where's the remaining 180gb of data!
[10:06:10] <Derick> ams__: maybe you have lots of gaps in the original data?
[10:06:30] <Derick> have a look at the collection counts - to see whether each collection has the same amount of documents?
[10:07:05] <Derick> it is not impossible that a new sync uses lots less data - especially if you were on an older MongoDB, and/or, you're now using WiredTiger with compression enabled.
[10:08:07] <Derick> ams__: can you show the few lines where the synching started too?
[10:09:06] <ams__> @Derick here you go https://www.irccloud.com/pastebin/uH5S2irp/
[10:09:55] <Derick> if that's all that's in the log, it seems... working
[10:10:23] <Derick> but do try to see if each collection has all the documents though
[10:10:30] <Derick> I can't see why it wouldn't though.
[10:27:05] <ams__> @Derick I have a lot of databases + collections, but picking a few it looks OK
[10:27:17] <ams__> But that's such a huge difference
[10:27:49] <Derick> sounds like a great feature :P
[10:28:25] <Derick> I think there might be a script to show the collection count for each collection in each db
[10:28:28] <Derick> let me dig
[10:28:28] <ams__> what, taking up 180gb unnecessarily?
[10:28:39] <ams__> cheers
[10:29:11] <Derick> no, losing 180GB with an upgrade ;-)
[10:29:13] <Derick> https://gist.github.com/matteofigus/8843247
[10:31:32] <ams__> ok shouldn't be too hard to modify that for my 150 databses :)
[10:32:09] <Derick> ams__: please share that though
[10:34:37] <Derick> or, should I write it?
[10:36:18] <ams__> ah, how do I pass a parameter to "use"
[10:36:53] <Derick> ams__: I have it written, let me upload
[10:37:03] <ams__> ok thanks
[10:37:13] <Derick> https://derickrethans.nl/files/dump/list.js.txt
[10:37:37] <Derick> oh hang on
[10:37:42] <Derick> that doesn't work 100%
[10:42:04] <ams__> 0 records :)
[10:42:09] <ams__> it claims
[10:42:10] <Derick> reload
[10:42:15] <Derick> it had a bug
[10:44:15] <ams__> great, thanks
[10:44:23] <ams__> now i just need to output to file and compare
[10:46:03] <Derick> mongo < list.js > output.txt
[10:46:07] <Derick> would do
[10:46:45] <Derick> maybe add --quiet
[11:23:31] <ams__> now i'm baffled
[11:23:50] <ams__> connecting from the local box, getCollectionNames() returns a list, from a remote box an empty list
[11:23:55] <ams__> Must be doing something stupid
[11:30:01] <joannac> are you sure you're connecting to the same mongod?
[11:31:55] <ams__> joannac: aha, it's https://jira.mongodb.org/browse/SERVER-16361
[11:32:44] <joannac> oh right, incorrect shell version
[11:41:51] <ams__> @Derick OK! The counts check out
[11:42:07] <ams__> Is there any way it could be lying to me? I'm quite nervous about shifting the master over
[12:44:00] <Derick> ams__: I can't see how.
[15:39:50] <mortal1> howdy folks, i have two collections, one that tracks job status (queued, processing, failed, etc) and one that has more info on the job itself. I need to query the 'job details' collection based off the jobId on the jobStatus collection. I'm on mongodb 2.6
[15:40:29] <mortal1> (we had issues with concurrency when trying to update the status on the original job collection, which is why we have two collections)
[17:08:38] <mortal1> could anyone give me advice on doing a subquery using a property from another collection?
[17:09:03] <mortal1> db.jobHistory.find({jobStatus:"FAILED"},{trackingId:1}).forEach(function(d){db.jobInfo.find({id:d.trackingId})});
[17:15:07] <cheeser> i'd do an agg with $lookup
[17:17:44] <mortal1> cheeser: man you are everywhere aren't you. i usually see you in ##java
[17:17:52] <mortal1> i'm on 2.6 sadly
[17:18:03] <cheeser> i'm Visa: everywhere you want to be.
[17:18:15] <cheeser> hrm. well, i'd expect what you have to work...
[17:18:40] <mortal1> yeah i think I'm gona map it into a var and use that var for another query
[17:18:44] <cheeser> instead of doing a query in that forEach(), try just printing out d and make sure you're getting what you think you are.
[19:30:14] <angular_mike> is there built in support for returning a random document from those that fit the query, while trying to ensure that they don't repeat for as long as possible?
[19:54:27] <cheeser> angular_mike: $sample?
[19:55:27] <n1colas> Hello
[19:55:34] <angular_mike> cheeser: will it keep outputting different documents each time I call it until there are no more documents left that haven't been output yet?
[20:06:17] <DammitJim> new to mongodb
[20:06:33] <DammitJim> I am creating users with passwords for different databases
[20:06:44] <DammitJim> is there no admin user password?
[22:01:20] <truckcrash> hunter2
[22:36:13] <angular_mike> truckcrash: ********
[22:37:20] <angular_mike> I want to filter document in collection by value range of some fields and then return a random one of the resulting documents. Should I use $sample?
[22:40:46] <cheeser> how else would you do it?
[22:43:12] <angular_mike> cheeser: I'm struggling with combining them together
[22:43:22] <angular_mike> it seems sampe only works in context of aggregation
[22:43:34] <cheeser> yes. so you'd $match then $sample i think.
[22:44:06] <angular_mike> cheeser: does match work with value ranges, like $lte and $gte?
[22:44:11] <cheeser> sure
[22:50:32] <angular_mike> oof, sample is new in 3.2
[22:50:35] <angular_mike> i've got 2.6
[22:53:41] <cheeser> OOF
[22:53:44] <cheeser> oops
[22:53:53] <cheeser> well, there's a good reason to upgrade. :)
[22:55:49] <angular_mike> ye, only Im trying to prototype as fast as possible without changing the environment right now
[22:56:51] <cheeser> you could always, query, count, query/limit(1)/skip(random(count))
[22:57:02] <cheeser> fugly but would get you there. mostly
[22:59:08] <angular_mike> cheeser: might do, everything is fugly right now
[22:59:23] <angular_mike> I hope noone ever sees it in the state it is right now
[23:02:06] <cheeser> hide your shame!