[01:42:14] <ARandomFurry> I'm getting a max call stack size exceeded error when calling myCursor.next(next); It bounces between serializeInto and serializeObject. Any thoughts?
[01:45:54] <ARandomFurry> Nevermind, I'll tackle this tomorrow when I've rested.
[01:50:15] <Trinity> When is the correct time to create indexes? After documents are inserted in?
[01:50:41] <Trinity> Also if I am starting with a fresh DB should I allow my application to enter the first documents or should I enter test documents first?
[01:51:03] <Trinity> would indexing work if there are no documents inside a collection?
[01:56:07] <joannac> indexing works even if there are no documents, it just has nothing to index
[01:56:45] <joannac> indexing earlier means queries can be satisfied with an index, but your writes will be slower because the document and index entries need to be written. It's a tradeoff and is your own decision about when it would be appropriate
[01:57:06] <joannac> whether you should put in test documents first is again, your decision.
[01:57:17] <Trinity> joannac, so if I index later will the indexing just take longer or will older documents not be indexed?
[01:58:02] <joannac> Trinity: the indexing will take longer
[01:58:19] <joannac> Indexes would be useless if they didn't index old documents
[01:59:03] <Trinity> joannac, also, in the documentation atomicity and transactions mongo docs states, Using two-phase commit ensures data consistency, but it is possible for applications to return intermediate data during the two-phase commit or rollback.
[01:59:14] <Trinity> what do they mean by return intermediate data or rollback?
[02:00:01] <Trinity> from what I understand, two-phase commits are basically writing atomically to a journal entry of the next operation you'll be doing
[02:00:01] <joannac> well, if you're halfway through updating, a clinet could theoretically see the intermediate data
[03:29:34] <troydm> Trinity: nvm, figured it out, well now I'm trying to use sqrt but it seems mongodb doesn't has this function
[03:29:43] <joannac> turns out I had misrememebered. Identical for MMAPv1 and WT as of 3.0
[03:30:48] <troydm> nvm, I needed to prefix it with Math.
[03:42:56] <charginghawk> can I have an '_id' like 'blog', or does it have to be a string of certain length, etc
[03:44:46] <Skaag> Hi guys, I'm trying to check what type of object is a certain field. I call: typeof db.test.age and it tells me it's an object
[03:44:51] <Skaag> it's supposed to be a Date object
[03:44:58] <Skaag> how do I get it to spit out the real type?
[04:07:24] <Boomtime> @Skaag: you are experiencing a javascript limitation (just FYI, this is not a MongoDB question in any way) -- typeof tells you the javascript type, and since javascript has no classes there are very few actual types
[06:31:27] <Boomtime> you need to go and read up on how exactly SSL works and then you'll have a chance of understanding the docs on how to set it up in mongodb (or anything else for that matter)
[06:31:54] <thapakazi> hmm, Boomtime would you recommend, how you learnt it ?
[06:32:12] <Boomtime> a very long time ago.. i don't really even remember
[06:32:20] <thapakazi> so lame, I don't know basics
[06:32:33] <Boomtime> search google for 'how to generate ssl certificates with openssl'
[06:32:46] <Boomtime> also, download and install openssl toolkit if you don't already have it
[06:32:55] <Boomtime> type "openssl -version" at the nearest terminal
[06:33:33] <Boomtime> when you can generate a certificate, then search for "how to validate certificates with openssl"
[06:34:09] <Boomtime> once you get pretty good at doing those steps with the openssl toolkit you'll pretty much understand what all the parameters are to mongodb ssl
[06:34:24] <Boomtime> also, you can test validating ssl certificates of your favourite websites etc
[06:35:01] <thapakazi> I have it all I guess, a generator too(yesteray I made one) https://gist.github.com/4b7d6f85d4e39bb06825e5457f9c4e1c
[06:35:57] <Boomtime> that's a self-signed certificate - you could use that as your own CA - search goolge for "how to sign your own certificates with openssl"
[06:41:01] <JeansenVaars> Hi All. Trying to test the Scala Driver here in Linux. Mongo server is running and I can connect through shell, but failing to connect through Scala code. Any assistance appreciated
[06:41:19] <JeansenVaars> Everything is pretty much default on localhost 27017
[06:45:26] <thapakazi> i wish I know Scala JeansenVaars, provide more context, if you are connecting with authentication or its open like stuffs for more appropirate helps
[07:05:42] <Trinity> why doesn't mongo offer transactions? it seems pretty easy to implement. This blog I came across is the best implementation i've seen so far http://trendblog.net/fix-soft-bricked-android-device-first-aid-guide/
[07:09:20] <Boomtime> @Trinity: your statement of claim is not based in reality, nor is the URL even remotely related from the look of it
[07:09:43] <Boomtime> also, MongoDB is an open source database, if transactions are easy to implement you should contribute a patch
[07:14:35] <Trinity> Boomtime, well i'd think the basic idea would be similar to how two-phase commits work right now. Start a transaction via driver method, add transactional steps, commit the transactional steps so it's written to some collection in database atomically. And run through each transactional step. If an error occurs it's all logged into the relevant document inside the transaction collection
[07:15:07] <Trinity> so you can rollback easily. I guess what i'm talking about is a library to abstract away two-phase commits
[07:18:13] <Boomtime> apparently you thought i didn't know how transactions work -- anyway, you should implement it and make a pull request, it's easy right?
[07:18:42] <Trinity> Boomtime, why are you so offended? Nowhere did I imply that you did not know how transactions worked.
[07:18:50] <Boomtime> also, are you aware that mongodb is a distributed database? how will you rollback a partial transaction between potentially thousands of nodes?
[07:19:52] <Boomtime> i'm offended because generally anybody who says in their opening statement that a specific feature implementation is "easy" invariably has no idea what they're talking about -- be less arrogant and i'll be more friendly
[07:20:53] <Trinity> I started off with a question, implying that I did not know why something was not done. There was no arrogance there. The only arrogance is the implied arrogance that you brought to the table
[07:21:38] <Boomtime> -> you're seriously claiming this was a simple question -> "why doesn't mongo offer transactions? it seems pretty easy to implement."
[07:21:58] <Trinity> is that a question or a statement?
[07:22:03] <Boomtime> please, a simple question is the first part, the second sentence is arrogance
[07:22:38] <Trinity> Possible from your prerogative
[07:23:11] <Boomtime> mongodb is a distributed system -- theoretically it would be possible to implement transactions in a constrained way
[07:24:15] <Boomtime> but in a useful way, like the open ended description you gave, would not be realistic -- admittedly it could still be done, but it would be dog slow due to having to coordinate so many interactions
[07:24:37] <Trinity> I see, thanks for that explanation Boomtime
[07:24:50] <Boomtime> fact of life is that the pacific is big, the speed of light exists, and mongodb can scale across continents
[07:25:36] <Boomtime> a transaction that could pull in and involve multiple members synchronising a commit across that distance would more often fail than succeed -- rollbacks would suck up half your resources
[07:26:06] <Boomtime> again, it could be done -- but a slightly careful design by the application can usually avoid any need for transactions
[07:26:55] <Boomtime> transactions are 99% of the time lazy programming -- there are some use cases that would be useful, that's a pain point but application document locks can get around it
[07:27:31] <Trinity> Boomtime, would you mind elaborating? How could you guarantee atomicity/ability to rollback without transactions and through careful design?
[07:27:51] <Trinity> Say for example the classic bank accounts problem that mongo docs state
[07:28:38] <Boomtime> you make your changes idempotent -- if you can't do that then you keep a ledger
[07:29:12] <Boomtime> i.e let us say you want to update a balance by "subtracting 5 dollars" -- your dependency on setting a new balance should be your understanding of the current balance
[07:29:45] <Boomtime> you start by recording what it is your about to change
[07:30:12] <Trinity> How is that any different than two-phase commits?
[07:31:04] <Boomtime> it isn't -- you can implement this -- but if you do it in a general way (say in a driver) then you don't know where the data resides
[07:32:14] <Trinity> Well with the driver it would just be abstracted away right? Not something you need to be concerned about. And even then the driver has to store that information somewhere albeit in a hidden collection or something
[07:32:23] <Boomtime> generally, a two-phase commit needs to use a very pessimistic model and performance is based on the idea that everything is happening in a close-by location -- btw, it can be mathematically proven that two seperate systems can never come to an agreement
[07:33:14] <Boomtime> two phase commit, in the way you're using it, is intended to solve this problem: https://en.wikipedia.org/wiki/Two_Generals%27_Problem
[07:33:17] <Trinity> I dont follow on that last statement. Everything is happening in a close-by location?
[07:34:30] <Boomtime> you can push the system into the future, but you can never guarantee that two systems commit a singular datum at the same time
[07:34:43] <Boomtime> which is what two-phase commit is trying to do
[07:35:00] <Boomtime> it can do if a single system has control of both pieces of data
[07:35:15] <Boomtime> (the ledger and the balance record)
[07:35:50] <Boomtime> but if these are distributed, as could happen in a general solution implmented in the driver of a distributed database product, it is mathematically impossible
[07:36:16] <Boomtime> with that said, you can get really really close
[07:36:34] <Boomtime> and you can implement it yourself, if you're careful and you understand your data model well
[07:36:41] <Trinity> so the gist of what you're saying is that it's possible but by abstracting it away you lose performance
[07:37:18] <Boomtime> that would be understating it significantly -- you wouldn't have a useful system at the end of it
[08:22:17] <kurushiyama> Trinity I have yet to find a use case where transactional integrity could not be achieved by clever data modelling – remember, document level operations are atomic.
[08:23:14] <Trinity> kurushiyama, would you mind giving me an example? Everything I can think of revolves around the concept behind two-phase commits
[08:23:32] <Trinity> and are heavily dependent on single document writes being atomic
[08:23:38] <kurushiyama> Trinity The easiest example would be accounts balances.
[08:24:00] <Trinity> For example my current issue: I have a physicalServer that can have 4-8 virtualHosts depending on how many cpu cores are available
[08:24:07] <kurushiyama> The general example in the SQL world does this: it deducts an amount of account X and adds it to account Y
[08:24:43] <Trinity> virtualServer and physicalServer are in different collections and each "server' would be a separate document
[08:25:07] <kurushiyama> Trinity You asked for an example, so please let me first finish it.
[08:25:42] <kurushiyama> Trinity This typical SQL approach lacks a crucial information: When was which amount transferred?
[08:26:46] <kurushiyama> Trinity So what you would do is to _document_ the transaction: {time: someISODate, amount:100, source: accountX, destination: accountY}
[08:27:37] <kurushiyama> Trinity Now, to get the balance of an account, you'd do an aggregation over the transactions. Problem solved. Ofc, this is a bit simplified, but it should be sufficient to get the picture.
[08:28:34] <Trinity> Isn't that a basic two-phase commit? Also if you wouldn't mind me asking how did you see my post from before O.o you joined recently
[08:29:16] <kurushiyama> Trinity it would be a simple insert
[08:30:18] <kurushiyama> Trinity There ia an irc-logger ;)
[08:30:51] <Trinity> kurushiyama, right, but wouldnt you still need to modify the documents of accountX and accountY (assuming they are stored in separate non-embedded documents) to reflect the balance?
[08:31:08] <kurushiyama> Trinity Also my example was a simple start to showcase that by smart data modelling, you can achieve a lot.
[08:31:59] <kurushiyama> Trinity You would not store the balance – you'd calculate it. Ever wondered why ATMs need some time before cashing out the money you asked for? Because this is what banks do, even with SQL databases. They calculate the balance.
[08:33:43] <kurushiyama> Trinity What you _could_ do is for example a daily preaggreation to get the balance of the account as of today, 00:00:00.000, and when doing a balance calculation for now, you'd only need to add and deduct today's transactions.
[08:34:25] <kurushiyama> Trinity But since you would do the aggregation of transactions within a set time, there again is no need for transactions – the operation is idempotent.
[08:35:08] <kurushiyama> Trinity So, that said, let us have a look at your use case.
[08:36:38] <kurushiyama> Trinity From first look, I'd say you overnormalized. That happens. It depends on the use case how small the path between overnormalizing and overembedding is.
[08:39:45] <kurushiyama> Trinity It would be helpful if you described what you want to _do_ so that we can have a look wether your data model fits your use case.
[09:20:37] <Trinity> kurushiyama, sorry for the delay. The gist of it is... I have a document named physicalServer that can have virtualServers. Each virtualServer will belong to a user. A vitualServer can only be created if a CPU is available on the physicalServer. A physicalServer only contains 8 available CPUs when it is first instantiated. So the general process looks similar to this, application needs to check for documents in the physicalServer collection to see
[09:20:38] <Trinity> which ones have available CPUs. It will select at random a physicalServer to use. It will then need to update the corresponding physicalServer's document to reflect the newly used CPUs and the new virtualServers that has been included so that if another virtualServer is added it will not select CPUs that have already been reserved. This virtualServer's meta data will then need to be added to the virtualServer collection and also be added to the u
[09:21:22] <Trinity> My currently implementation goes as following: Add all information regarding this transaction to a transaction document and then proceed with the updates while updating the transaction as necessary for each step this way I can rollback if anything occurrs
[09:22:02] <Trinity> what I am confused about is whether or not this method would work for a replicated or sharded db although I have no immediate plans for sharding but I may consider replication.
[09:22:26] <Trinity> And also if it is the most efficient implementation for my issue
[09:23:07] <kurushiyama> I'd embed the virtual servers into the physical ones.
[09:24:30] <Trinity> kurushiyama, but they wouldn't be related and virtualServers may include other meta data that would be completely unrelated to physicalServer. Perhaps i'm thinking too much in the traditional RDBMS way
[09:25:54] <Trinity> the only relation between virtualServers and physicalServers are that they are a part of physicalServers. And most data writes/reads stem from virtualServers rather than physicalServers
[09:27:47] <Trinity> kurushiyama, furthermore I will still need to update the 'user' collection so i'll still need to utilize some sort of two-phase commit
[09:30:46] <kurushiyama> Trinity Well, that is only partially true: The data of the virtual servers is related to the physical server, as it is related to a machine running on that server.
[09:31:09] <kurushiyama> Trinity And yes, you are thinking too much SQL
[09:31:22] <kurushiyama> Trinity What would you need to update in the users collection?
[09:31:36] <Trinity> kurushiyama, that the user now owns this said virtualServer
[09:31:50] <Trinity> I guess it would be more accurate to say virtualProcess as that is what the user actually gets
[09:31:54] <kurushiyama> Trinity BS , sorry for the french
[09:32:15] <kurushiyama> Trinity virtual server doc: {..., owner:userid}
[09:32:42] <kurushiyama> Trinity No update needed in the user collection
[09:34:00] <Trinity> hmm interesting. I was going to argue that you'll then need more reads but it would end up being the same I suppose
[09:34:20] <Trinity> more reads because once the user logs in they'll already have their user data
[09:34:54] <Trinity> kurushiyama, so what would you define as reasons to use separate collections vs embedded documents?
[11:09:21] <ArGGu^^> Derick project that I am working currently, is multisite. And I would like to know how much each site consumes storage.
[11:10:12] <Derick> ArGGu^^: as a one off thing, or constantly?
[11:11:09] <ArGGu^^> constantly, I would store the information somewhere and update always when new data is inserted in database.
[11:11:58] <Derick> ArGGu^^: it would be a very slow operation - I would recommend just using multiple databases
[11:12:37] <ArGGu^^> Derick ok, the reason for it is to limit the storage per site.
[11:14:58] <ArGGu^^> Derick but when I update the values, I only need to update the changed. So would that be slow? I mean I could insert new document and then just check it size and add it into storage counter.
[11:15:55] <Derick> ArGGu^^: it's really figetty to get right, where the data size is just a property to read for a database (or rather, the collections that make them up)
[11:17:52] <ArGGu^^> Derick you mean the document size that example Object.bsonsize returns, would not be equal to the bytes on disk?
[11:20:08] <ArGGu^^> Derick because if it would be then I just update single value per site when I insert/update/replace/remove in database.
[11:21:32] <tantamount> Derick, thanks for Xdebug, by the way. It's great ;^)
[11:28:23] <Derick> ArGGu^^: only sortof - there is overhead in the DB of course
[16:05:30] <atbe> Hey cheeser sorry I missed any messages, I saw your pr
[16:13:11] <cr0mulent> Hello, I am new to mongodb. I am looking to query an existing database which has keys where the value references the objectid in another collection. For instance, language : {ObjectId: …} is this considered a foreign key in mongodb parlance? Could someone point in the right direction for joining values from two collections?
[16:14:42] <cheeser> you can query by that key value but joins aren't entirely a mongodb thing. there is $lookup, though, https://docs.mongodb.com/manual/reference/operator/aggregation/lookup/
[16:19:05] <havardge> Hi, I am seeing slow lookups on id in my application. I use the current release of Spring Data in a Spring Application.
[16:19:20] <havardge> My lookup is simply a MongoTemplate#findById(...)
[16:20:42] <havardge> (not using DBref, but embedding the list into my document)
[16:21:10] <havardge> Can someone point me in the right direction of figuring this out, perhaps it is even as expected?
[16:23:23] <havardge> It seems strange that 150 findOne(...) queries on an indexed field should take 1000ms
[16:28:00] <atbe> cheeser: I understand that this fix will only make it's way in after the next release, but is there any way I can get a build with the fix integrated earlier than that?
[16:37:59] <cheeser> you can use a SNAPSHOT build if you're comfortable with that. or build a local copy.
[16:39:10] <xQuasar> Hi, apologies if this isn't the right place, but I'm working with MongoDB 3.2 in Java and I wanted to only select a few fields from my "clusters" collection, so I used projections as follows:
[16:51:48] <atbe> cheeser: no worries, thank you for following up and getting it checked out. I will wait for an official release just to be safe and so my qa guys can test it thoroughly.
[17:32:26] <oded> I'm having a replicaset, but the client using mongoid doesn't seem to care that the primary is gone and gets execution expired errors instead of switching to the new primary
[17:32:42] <oded> Am I missing some configuration?
[17:37:52] <kali> oded: most of the time, the driver does not proactively reconfigure itself. it just let the failing connection go and open new ones with the reconfigured replicat.
[17:38:54] <kali> oded: so you should get a few errors, probably as many as the number of open connection the driver is keeping in its pool, but then you should be fine
[17:39:41] <oded> kali: ok so I actually removed the downed server from the client configuration and restarted it, and I'm still getting "MONGODB | execution expired"
[17:40:07] <oded> I'm seeing at the backup server (this is what I'm testing now) that the client has connected though
[17:40:26] <oded> What could cause "MONGODB | execution expired"?
[18:01:27] <cheeser> atbe: jeff didn't fix it! i did! :)
[19:01:02] <atbe> cheeser: :X mane I don't what cheeser corresponds to :P Are you Evan?
[19:31:27] <ceecko> hi, I'm looking for help with a strange issue. I have 1 member replica set configured and can connect via mongo shell, however via the node driver I always get error "MongoError: no primary found in replicaset". Everything worked correctly up until now and we only ran db.repairDatabase() in the meantime. Any ideas?
[19:48:19] <cheeser> ceecko: does rs.status() show things as ok in the shell?
[19:48:55] <checklist> Hi -- I have a quick question about schema configuration, and I was wondering if anyone had any suggestions?
[19:49:07] <ceecko> cheeser: yes, everything is ok
[19:49:33] <cheeser> hrm. i don't know anything about the node driver unfortunately.
[19:49:38] <ceecko> cheeser: one member in state:1, stateStr: PRIMARY
[19:49:41] <cheeser> i mean, other than it's written in js, of course.
[19:50:08] <ceecko> cheeser: yeah, I'm just looking at mongodb-core if there wasn't any changes for one member replicaSets...
[19:50:26] <checklist> Free SO upvotes for anyone that wants it http://stackoverflow.com/questions/38381034/checkbox-option-type-monodb-schema-design
[19:54:56] <checklist> Anyone have any suggestions?
[20:04:39] <ceecko> cheeser: I just discovered this is an issue of the latest Mongodb node driver. The issue was not present in older version and I've already opened a ticket in Jira NODE-758
[20:12:00] <Karbowiak> hey guys, i'm rather new to this whole mongodb ordeal, and i'm trying to update a field (a timestamp) that is mistakenly set as a string, to a Date field, and i'm not 100% sure i'm doing this correctly, but so far this is the query i've put together: db.getCollection('killmails').updateMany({"killTime": {$type: "string"}}, {$set: {"killTime": new D
[20:12:01] <Karbowiak> ate(killTime)}) not sure the last part killTime is right
[20:20:51] <cheeser> you should try that new Date("...") bit in the shell first.
[20:24:36] <Karbowiak> figured it out, had to use a .forEach and some javascript
[20:24:53] <Karbowiak> was actually easier than i expected, still not sql easy, but easier than i would've figured :D
[20:27:19] <cheeser> oh, right because you can't access the document field value in the update
[20:27:52] <Karbowiak> nop, bit weird / annoying, but oh well
[20:27:58] <Karbowiak> can't have everything in this world i guess
[20:28:55] <cheeser> that's a gap i wish we'd fill, though.
[20:29:52] <Karbowiak> would make it all a fair bit more transparent to figure out
[21:04:23] <hdon> hi all :) i'm reading http://blog.mongodb.org/post/88473035333/6-rules-of-thumb-for-mongodb-schema-design-part-3 and i want to know if there any frameworks out there to help abstract the application away from the exact structure of your schema. if i change my mind about denormalizing some particular relationship, how can i avoid rewriting my application code?
[23:42:03] <MacWinner> is .update() with upsert: true supposed to be atomic?
[23:42:27] <cheeser> all document updates are atomic
[23:42:56] <cheeser> a simultaneous call might try to insert two docs at once, i would imagine
[23:42:57] <MacWinner> i think i have a racecondition where 2 updates with upserts come in at the same time.. the second one creates a new document instead of updating the first document
[23:43:50] <MacWinner> ahh.. so the second query could perform the search before the first query actually inserts the data?
[23:44:29] <MacWinner> is there a simple solution the ensure the second update always modifies the first document?
[23:45:35] <cheeser> your application could centralize/serialize those creations.
[23:46:35] <MacWinner> got it, thanks! i should read teh docs.. it's clearly stated there: "To avoid inserting the same document more than once, only use upsert: true if the query field is uniquely indexed."