PMXBOT Log file Viewer

Help | Karma | Search:

#mongodb logs for Wednesday the 31st of December, 2014

(Back to #mongodb overview) (Back to channel listing) (Animate logs)
[00:08:07] <gundas> Hi all, I'm trying to insert a JS object with a date in it (ISO format) into mongo however mongo keeps thinking the date is a string, is there a way to force it to recognise it as a timestamp?
[00:18:41] <pbryan> I seem to be successfully using multikey index with two array keys, in contradiction with the documentation. Does this really work or am I smoking crack?
[00:19:14] <pbryan> (BTW, on 2.6.6)
[00:19:36] <pbryan> They're simple arrays of strings, not arrays of documents.
[00:19:58] <pbryan> Query plan shows index is being used when querying these arrays for various values.
[04:38:58] <Gern> Hi all, I got a really confusion problem with mongodb. Can someone help me out ?
[04:39:17] <Gern> *confusing problem
[04:43:53] <joannac> it might help if you tell us what the problem is
[04:43:57] <joannac> Gern: ^^
[04:44:32] <Gern> :) Can I post a link to a stack overflow question?
[04:45:20] <joannac> sure, i guess
[04:46:05] <Gern> http://stackoverflow.com/questions/27713027/mongodb-php-mongoid-confusion
[04:49:00] <joannac> does the PHP driver automatically populate whatever $a is with whatever ObjectID it is assigned?
[04:49:04] <joannac> that seems confusing to me
[04:49:38] <Gern> Yes, PHP driver populate $a with the ObjectID automaticaly
[04:49:57] <joannac> when you go to the mongo shell, is there only one document in the collection?
[04:50:10] <Gern> Yes
[04:50:27] <joannac> I want to see what you do in the mongo shell, including how you call the mongo shell
[04:51:05] <Gern> I open the mongo cli
[04:51:15] <Gern> then, "use mydb"
[04:51:24] <Gern> and "db.test.find()"
[04:52:01] <Gern> { "_id" : ObjectId("54a31a8d95463450568b4589"), "name" : "a" }
[04:52:13] <joannac> drop the collection in the mongo shell, then do the whole thing again
[04:52:33] <joannac> (make sure it's reproducible)
[04:52:41] <Gern> db.test.drop()
[04:53:17] <Gern> ran the PHP code, ID of A = 54a380be9546347a4e8b4567
[04:53:33] <Gern> db.test.find()
[04:53:43] <Gern> { "_id" : ObjectId("54a380be9546347a4e8b4568"), "name" : "a" }
[04:56:01] <Gern> it's reporducible, tried to flush my ubuntu VM, reinstall the whole thing. Always the same result : ID reported to PHP is not the same one as Mongo
[04:56:44] <joannac> If you specify an object id in $a, does it get saved correctly?
[04:59:19] <Gern> specified ID = 54a380be9546347a4e8b4567
[04:59:21] <Gern> { "_id" : ObjectId("54a380be9546347a4e8b4567"), "name" : "a" }
[05:00:07] <Gern> :/
[05:03:32] <joeyjones> Gern: crazy, i have no problems on windows or centos with PHP's library
[05:04:10] <joannac> Yeah, not sure
[05:04:24] <Gern> 32bit or 64bit ?
[05:04:42] <joeyjones> 64-bit
[05:04:46] <joeyjones> you?
[05:04:49] <Gern> 32
[05:04:51] <joeyjones> wait
[05:04:56] <joeyjones> let me check php itself
[05:04:58] <joeyjones> the system is 64
[05:05:22] <joeyjones> windows is 32, centos is 64
[05:05:51] <joeyjones> Gern: can you connect with Robomongo and see what it shows?
[05:06:14] <joeyjones> also, how are you inserting and fetching with PHP?
[05:06:38] <Gern> I'm inserting with PHP, fetching with the mongo shell
[05:06:47] <Gern> what is Robomongo ?
[05:08:06] <joeyjones> Gern: do you have journaling enabled in MongoDB?
[05:08:37] <joeyjones> Try doing the insert like this: $mongoUser->insert($newUser, array("j" => true));
[05:09:21] <Gern> journal=true in the conf
[05:10:03] <Gern> j = true did not help
[05:11:03] <joeyjones> strange
[05:11:52] <joeyjones> Robomongo is an IDE that allows for viewing.editing, it's what I've been using and it always matches
[05:12:42] <Gern> I'm installing it
[05:13:52] <joeyjones> also try displaying $a['_id']->{$id}
[05:16:47] <Gern> (string)$a['_id'] == $a['_id']->{$id}
[05:17:10] <Gern> Robomongo shows the same ID that mongo shell
[05:18:13] <joeyjones> Well, I'm stumped.
[05:18:27] <joeyjones> My next suggestion would be to get your PHP up to a newer version
[05:18:49] <Gern> Also, in PHP, after I inserted A, if I print iterator_to_array($collection->find()) I see the same ID of $a['_id']. But if I refresh the page and only print iterator_to_array($collection->find()) (without inserting first) I see the ID of mongo shell...
[05:19:04] <joeyjones> I'm running 5.5.15 and 5.5.20
[05:19:31] <joeyjones> crazy
[05:19:34] <Gern> Ok gonna try that
[05:20:04] <joeyjones> even if it doesn't solve the problem you'll be better off on a newer version anyway
[05:20:50] <joeyjones> I'm afk to get some food, bbiab
[05:25:00] <Gern> Thanks joeyjones & joannac. I'm gonna update my dev VM to match my live environnement and see if that solve the problem
[06:01:06] <joeyjones> Gern: any luck with the update?
[06:01:28] <joeyjones> and yeah, you should always try to keep the PHP major versions matching between prod and dev
[06:01:47] <Gern> Not yet done with the update
[06:02:12] <Gern> I know my dev VM is far behind... haven't updated it for the past5 years :)
[06:17:05] <pbryan> On 2.6.6, I seem to be successfully using an index with keys, both which contain arrays of strings. This seems to contradict the documentation. Query plan explains I am using the index. How is this working?
[06:18:47] <joeyjones> lol Gern
[06:18:53] <joeyjones> it is an endless struggle
[06:19:10] <Gern> joeyjones, updated my dev VM to 64bit and PHP 5.6.4 and the problem persist
[06:19:28] <joeyjones> but a dev environment that doesn't match prod isn't that useful
[06:19:31] <joeyjones> and damn
[06:20:55] <Gern> Yeah but keeping up with my 10+ servers which have all different setup is kind of hard. I keep a dev VM with the common minimum
[06:21:55] <joeyjones> geez
[06:22:14] <joeyjones> yeah, i hate when the prod environments get spread out
[06:24:11] <Gern> Could it be just a problem with the way the ID is generated? Maybe I'm missing a config in PHP and that MongoId that get automaticaly generated is ignored by mongo ?
[06:24:33] <joeyjones> no, that shouldn't be the problem...
[06:26:16] <joeyjones> it seems to me like the is being altered after the insert, or you may be trying to insert on top of an existing id in which case the db isn't changed but _id is generated client-side so you have a new id on your end
[06:26:24] <joeyjones> *the id is being
[06:28:28] <joeyjones> ie. you may have a unique index on the name field so the insert fails but _id is still created
[06:28:59] <joeyjones> try putting a random value in or something
[06:31:20] <Gern> same problem
[06:34:09] <Gern> what bugs me is that when I specify a ID, its ok
[06:43:34] <Gern> I also tried to insert 1 document with a ID of "54a399eefa4634d3388b458b" and a second one with new MongoId(). Mongo shell shows the first one is correct and the second one is wrong
[06:44:55] <Gern> Even if I try to convert new MongoID() to string first, it get altered anyway
[06:45:42] <Gern> Look's like that everything that resemble a newly MongoId gets altered
[06:46:31] <zzing> Is there a proper regex for an objectid?
[06:52:33] <joeyjones> Gern: and you're use the mongo extension in PECL, right?
[06:54:11] <Gern> yes
[06:57:55] <joeyjones> this is crazy
[06:59:33] <Gern> is mongo 2.6.6 stable ?
[07:03:22] <joeyjones> I'm on 2.6.5 but I have no idea. I've been using Mongo for less than a week.
[07:06:17] <Gern> gonna try 2.4.12
[07:07:24] <joeyjones> i swear that there will be some stupidly simple bug somewhere that caused this all
[07:10:06] <Gern> didn't change anything, everything that look like an mongoid, even if it's in an other field like "test" or "dfskadfhkufsd" get altered like _id is
[07:11:13] <joeyjones> i think i may have found something
[07:11:39] <joeyjones> the last 3 bytes of the mongoid is a counter
[07:11:49] <joeyjones> http://docs.mongodb.org/manual/reference/object-id/
[07:26:41] <Gern> ok I'm dropping it
[07:26:55] <Gern> Thanks anyway
[07:33:43] <Avihay_work> Hi, I have a local DB and a remote DB. I mongodumped my local, uploaded and mongorestored on the remote system.
[07:34:56] <Avihay_work> I can run mongo on the remote system and connect via a user and password
[07:37:06] <Avihay_work> but when I run >show collections or > db.phones.find() on the remote system, it fails with 2014-12-31T00:29:21.033-0700 error: {\n "$err" : "not authorized for query on CMwebapp.system.namespaces",\n "code" : 13} at src/mongo/shell/query.js:131
[07:37:24] <Avihay_work> while it runs perfectly fine on the local system
[07:41:59] <Avihay_work> local version 2.6.3 remote 2.6.6
[07:43:53] <ollivera> After a reboot I can't authenticate on secondary ... I stopped the secondary, removed all files from dbpath and started again ... all dbs have been copied .. due the sync ... but user information how can I restore the user information in the secondary so much so that I can authenticate again?
[07:49:00] <ollivera> I can't see the system.users collections in the secondary
[07:50:16] <Avihay_work> you should be able to roll over the users collection with mongorestore
[08:11:45] <Avihay_work> ah, I didn't have auth on on the local server, now both of them fail, JOY!
[08:17:00] <ollivera> Avihay_work: it didn't work ... after restore a backup .. no system.users, only system.indexes
[08:20:31] <Avihay_work> did you look at the command output? mine was http://pastebin.com/aLjNVd5p which suggests it restored both my "admin.system.roles" and "admin.system.users"
[09:06:34] <ollivera> Avihay_work: okay, it seems that I don't store users in admin database, it is stored somewhere else, so that's why it is not restored
[12:30:37] <crised> Hi, What's exactly is an index in mongodb?
[12:31:14] <crised> Is what mongodb internally uses to save data, or is it the "primary key" that we use?
[12:31:25] <crised> cheeser: Hi
[13:20:52] <crised> Can I see the oplog of a given db only?
[13:21:40] <joannac> no, but you can search the oplog for just that database
[13:21:48] <crised> I get a not autorizaed code 13 in Mongolab, using rs.printReplicationInfo()
[13:21:48] <crised> https://gist.github.com/crised/364ef9b9031421f8bd65
[13:21:59] <crised> joannac: how?
[13:23:13] <crised> db.getReplicationInfo() -> code 13 not authorized...
[13:24:12] <joannac> uthenticate?
[13:24:34] <crised> joannac: I'm authenticated
[13:24:42] <crised> joannac: using mongolab
[13:24:56] <joannac> then you dont have sufficient privileges
[13:25:14] <joannac> do you have read access on the local db?
[13:25:24] <crised> joannac: maybe I'm trying to see the oplog of other dbs
[13:25:28] <crised> joannac: yes, I just inserted
[13:26:02] <joannac> there's only one oplog per instance
[13:26:27] <crised> joannac: 1 instance has many mongodbs, right?
[13:27:24] <crised> joannac: MongoLab-> "you can create a user with oplog access on all for-pay plans."
[13:27:51] <crised> joannac: using free plan...
[13:28:58] <joannac> okay, then you don't have access
[13:29:00] <joannac> try
[13:29:04] <joannac> use local
[13:29:24] <joannac> db.oplog.rs.findOne()
[13:29:44] <crised> switched to local, same... code 13
[13:30:13] <joannac> right, you don't have access
[13:30:25] <crised> joannac: sure, I'm saying only the info of my db?
[13:30:35] <joannac> can't
[13:30:43] <crised> joannac: can't?
[13:30:54] <joannac> there is only one oplog per instance
[13:31:12] <joannac> if you don't have access, then... you don't have access
[13:31:15] <crised> joannac: I understand, but can I access through a special command, the info of just my db
[13:31:20] <joannac> no
[13:31:40] <joannac> there is no special command
[13:32:01] <crised> joannac: mmm... I don't want to actually see what's inside of oplog, I just want to know when there is a change in the db
[13:32:08] <crised> joannac: is there a special command for that?
[13:32:29] <joannac> check rs.status and the optime field
[13:32:40] <joannac> if that changes, there's been a write
[13:32:56] <crised> function () { return db._adminCommand("replSetGetStatus"); }
[13:33:33] <joannac> yes, put brackets in
[13:34:27] <crised> joannac: https://gist.github.com/crised/a4a2e89da20a46d5c336
[13:36:42] <joannac> yeah, you're out of luck
[13:37:45] <joannac> the free tier is a shared instance anyway, so that won't work
[13:39:27] <crised> joannac: so the paid shared will behave just like this?
[13:40:50] <joannac> the paid shared plan looks like a dedicated mongod instance in a shared VM
[13:41:04] <joannac> I would expect you would have permission to look at the oplog, run rs.status(), etc
[13:41:32] <crised> joannac: in a clustered enviroment, rigth?
[13:41:56] <joannac> I don't know what you're asking
[13:42:25] <crised> joannac: you say it's a dedicated mongo instance, shoudn't them be replica? like 3 mongo instances?
[13:42:53] <joannac> sure, looks like it
[13:43:05] <joannac> it says it has HA
[13:43:34] <crised> joannac: I could do the same by having 3 ec2 micro instances, right?
[13:43:58] <joannac> oh, looks like shared doesn't get you oplog access either
[13:44:09] <crised> joannac: yes, it does
[13:44:12] <crised> I'm seeing ti
[13:44:52] <crised> It doesn't have full database administrative privileges
[13:45:40] <joannac> i highly doubt you would get much done on a micro
[13:45:48] <joannac> not enough RAM
[13:46:08] <crised> joannac: my db requierments are very low
[13:46:28] <crised> joannac: I just want to have HA, How can I achieve that?
[13:48:18] <joannac> have HA for what?
[13:48:59] <crised> joannac: I just want to avoid downtime as much as possible, mongolab seems nice, but I don't like this restricted privileges thign
[13:49:56] <joannac> okay, put it this way. if you have very very low activity, and a very small database, then i guess it could work?
[13:50:33] <crised> joannac: I have extreme low db activity, small db, yes but I want to have full admin rights
[13:50:51] <joannac> sure. set up your own replica set on some micros then
[13:51:49] <crised> joannac: ok...
[13:51:55] <crised> Do I need 3 instances for that?
[13:53:01] <joannac> ...yes
[13:53:10] <joannac> think about that question some more
[13:54:19] <crised> joannac: mmm, yes, so 3 micro instances.
[13:55:04] <crised> joannac: $75 per year x 3 -> 225 / year -> 18 / mo
[13:55:30] <crised> joannac: Do I need some kind of tweaking or something like that to deploy a replica set on ec2?
[14:00:58] <joannac> http://docs.mongodb.org/ecosystem/platforms/amazon-ec2/
[14:02:49] <crised> joannac: I see, it's a standard procedure...
[14:03:29] <crised> joannac: If I choose mongolab, and I do have oplog access, What would I miss from having full admin privilige?
[14:06:06] <joannac> i have no idea, it depends on what privileges you get from mongolab
[14:16:11] <crised> joannac: There are many platforms there ec2, dotcloud, google, joyent... which of those is the most straight forwarrd way to set up a replica set
[14:19:56] <joannac> the steps to start a replica set aren't really related to your hosting provider
[14:21:15] <crised> MongoDB runs well on Amazon EC2.... doesn't specify size of instance...
[14:21:45] <joannac> that's because it's dependent on what you're doing
[14:24:45] <crised> joannac: mmm, I think for my case a small app, I should be delegating db stuff to a service provider, only thing that frightens me is the restriction of privileges
[14:30:53] <joannac> well, if you want a managed service, then that will always have a price tag and come with some restrictions
[14:43:17] <crised> joannac: very true
[14:43:51] <crised> fow low data, I believe managed service should be more cost effective
[18:27:55] <crised> Do you guys normaly use mongodb with a web ui? Or you just use the shell to view/sort data?
[18:28:04] <crised> joannac: ^
[18:35:52] <jumpman> crised, I don't use mongo with any UI
[18:36:08] <jumpman> but my coworker showed me the UI he uses which had some cool features as well as inline-editing as if the db was json
[18:36:45] <jumpman> I want to set it up, but haven't got around to it yet
[18:37:58] <jumpman> I have kind of a curiosity question. Untrusted code can run Update and Insert. Why not Upsert?
[18:38:29] <jumpman> oh. wrong chan.
[18:53:13] <crised> jumpman: thanks
[18:54:15] <crised> Since _id is comprised with a timestamp as well, can I rely on this timestamp? I mean, can I do queries that uses the timestamp information? e.g. all of the persons inserted after year 2013?
[18:55:23] <crised> Is _id an index of mongodb?
[18:55:28] <alexgg> you can
[18:55:46] <alexgg> with two restrictions
[18:55:55] <alexgg> your servers have to be time synchronized
[18:56:06] <alexgg> and you don't need sub-second precision
[18:56:08] <crised> alexgg: is this a good practice, since I might avoid using a timestamp in the app
[18:56:23] <crised> alexgg: Why do they need to be time sync?
[18:56:24] <alexgg> I used it in the past, worked well
[18:56:54] <crised> alexgg: just because they show accurately the time, or is it because of some internal mongodb thing?
[18:56:56] <alexgg> well, if one server has +1hr compared to the other, it will generate timestamps that are always +1hr
[18:57:17] <crised> alexgg: ok, I get that, but it won't break anything
[18:57:21] <alexgg> nope
[18:57:30] <crised> if not, I read in mongodb book, that servers don't need to be time sync
[18:57:36] <crised> but of course it's better that they are
[18:57:55] <crised> alexgg: is _id an index of the database, right?
[18:58:11] <alexgg> yes, it's the default "primary key", an unique index
[18:58:21] <crised> alexgg: thanks bro
[19:39:35] <Gern> I'm back with my absurd problem guys...
[19:40:06] <crised> If I add an index to my collection
[19:40:55] <crised> When find() gets called, how to get items sorted by time of insertion?
[19:45:04] <crised> In other words, if I add no index, when I call find() it will return the documents as they were inserted
[19:45:25] <crised> so how can I add an index, and have that *natural order*
[19:46:36] <RaceCondition> when using a tailable cursor, if my app restarts, will the cursor continue to return documents where left off?
[20:25:50] <sellout> There seems to be a bug in $where selectors: { "$where": function () { return x; } } works, but { "$where": "x" } doesn’t (zero documents pass the filter) when `x` contains an anonymous function. Has anyone else seen something like this?
[20:53:03] <dimon222> >crised - web ui
[20:53:15] <dimon222> shell <3
[20:53:23] <dimon222> but Robomongo is cool as well
[22:00:31] <crised> dimon222: wgat??
[22:00:49] <crised> shell is better than web ui?
[22:00:49] <dimon222> <crised> Do you guys normaly use mongodb with a web ui? Or you just use the shell to view/sort data?
[22:00:57] <dimon222> depends
[22:01:02] <crised> dimon222: yes, but I don't understand those marks
[22:01:12] <crised> <3 means happy?
[22:02:35] <dimon222> sometimes when yes
[22:02:36] <dimon222> luv
[22:02:44] <dimon222> meh, drunk already, new year :D
[22:03:02] <crised> dimon222: mmm, if the db is not exposed to the internet... there is no way to have web ui
[22:03:19] <crised> I read that it's best to have mongodb servers without external internet access
[22:03:34] <crised> dimon222: happy new yeaer, it's 7:00 pm here,
[22:03:57] <dimon222> hehe, 5:02 PM here, but relatives are from europe so
[22:04:06] <crised> dimon222: lol
[22:04:08] <dimon222> anyway, yes, its bad for security
[22:04:18] <crised> dimon222: from which part of europe?
[22:04:31] <dimon222> Austria
[22:04:37] <crised> Spitze
[22:05:02] <dimon222> web ui is bad for security, but its more friendly for non-OS related people
[22:05:31] <dimon222> so basically for people who dont want to be involved in actual coding like business people
[22:05:45] <crised> dimon222: I see... no web ui atm then
[22:08:26] <dimon222> however, you can use something like SSL certificates and such stuff to make it secure
[22:08:59] <dimon222> at least little bit more than most of average users do
[22:14:44] <crised> dimon222: mmnm, better to have it isolated in a amazon vpc, don't you think?
[22:16:06] <dimon222> obv yes
[23:57:52] <mordof> I've not worked with mongo much.. right now i'm trying it more as an experiment - currently I'm looking into storing x,y coordinates with each collection entry. I've seen mention of 2d indexes, or geojson coordinates, but i'm not quite sure how to go about using them (or if that's even exactly what i want). anyone know of a decent spot for me to start reading up on this topic?