MongoDB 4.0 will add support for multi-document transactions
mongodb.com
mongodb.com
PostgreSQL with JSONB columns seems to have beat them to the race by quite a wide margin. MySQL too, for that matter.
Also, we can use SQL.
> By default, multi-document transactions wait 5 milliseconds to acquire locks required by the operations in the transaction. If the transaction cannot acquire its required locks with the 5 milliseconds, the transaction aborts.
Automatic cancellation rather than actual deadlock detection is going to be one hell of a footgun.
I'd argue this is a double barreled footgun as most usage of MongoDB is from garbage collected languages. One wrongly time GC and your transaction is dead.
Yes it's a play on shooting yourself in the foot, the idea is that you designed a gun designed to shoot yourself in the foot.
Are the locks not database-side, rather than client-side?
Well, this would be in keeping with MongoDB's track record, sooooo
There's a chance of data loss, of course, but the write performance is so good that it's a perfect fit for workloads like analytics or logging.
That’s not how it works. The transaction as a whole is sent to Mongo for execution server side; the client isn’t manually controlling transaction execution.
In the example on the docs page it looks like the logic is happening in the app code: https://docs.mongodb.com/master/core/transactions/#retry-tra...
Granted it's only writing to some collections but I assumed you can read from the session during a transaction.
> The transaction as a whole is sent to Mongo for execution server side; the client isn’t manually controlling transaction execution.
Are you saying that transactions are serialized as a series of pure updates and sent to the server as such? i.e you can't read a value, use it for some logic, update some other values, repeat ..., then commit? If that's the case this would be better labeled as "Multi-document atomic updates" as (to me) transaction implies interaction with the data in app code.
Not quite. The code in the docs you linked to handle what happens when a transaction does not complete server-side -- typically, you want to re-try the entire transaction a few times in case transient locks have been released or preconditions met. It does not suggest that the transaction is being controlled/orchestrated by the client.
> Are you saying that transactions are serialized as a series of pure updates and sent to the server as such?
Yes, generally. Check out examples of Postgres transactions -- they are plain-text "queries" that are executed with all-or-nothing semantics.
> (to me) transaction implies interaction with the data in app code.
Transactions, generally, are groups of statements/queries that are either all applied or none at all. They do not imply interaction with the data in app code, unless the app code itself is executed as part of the transaction itself (e.g., UDFs or stored procedures). They are like mini-programs that are shipped to the DB to be executed in a concurrency controlled and undo-able environment.
Even though I may like e.g. Postgres features more, there is still something to be respected about how MongoDB has operated, and the constant vitriol about their chosen priorities has always sounded hollow to me, even accounting for stories about data loss, etc.
Incidentally, I once had the chance to tour the MongoDB office near Times Square, and boy, I can tell you it is not an office environment for me. Extremely loud, and they even have things like scooter parking slots and signs for “scooter etiquette” for rolling around the office on a scooter.
I’m not sure how they are able to focus on any engineering work, but kudos to them for finding a way.
Every offering has its' issues but most of the time there is one feature that makes dealing with these worth it.
MongoDB is a marketing meme that slowly has had a database built around it.
Personally I think the idea for MongoDB is not that bad. It's just not one that works for business scenarios, where traditional principles are mandatory.
But, the bread-and-butter business stuff has continually left me disappointed and sometimes working way harder than needed.
Personally, I think that usability shouldn't be the primary decision criteria in a database for most engineers, even if it is a successful strategy.
Also: This is going to be really nice, but I sure hope a major cloud provider starts providing a managed service. It's very nice having a managed service like Amazon RDS or Google Cloud SQL.
MongoDB Atlas is a cloud-hosted MongoDB service engineered and run by the same team that builds the database. It incorporates operational best practices we’ve learned from optimizing thousands of deployments across startups and the Fortune 100. Build on MongoDB Atlas with confidence, knowing you no longer need to worry about database management, setup and configuration, software patching, monitoring, backups, or operating a reliable, distributed database cluster.
Since you mentioned you work for MongoDB, if you guys could partner with Heroku and add Atlas to their official add-ons our team might be able to take a look and switch ;)
https://blog.openshift.com/dev-preview-mongodb-enterprise-ru...
I actually witnessed that once when a customer (and mongodb user) had some man power from an agency allocated and one of those guys mentioned RDS. I wasn't impressed.
I mean, I think if I needed to think beyond sql, a graph db like arango or neo might make more sense...
This is also because I think of mongo as generalist, which may or may not be right.
It seems as though there are better choices for more specific use cases
It's not like you couldn't rip out mongo in MERN and use PERN or MyERN (Mysql Express React Node). There's some good libs/packages for using relational db's, and the benefits may outweigh those of Mongo.
I guess one other use case maybe would be an incremental/idle game, where all data is just stored as one big json doc, and you just need to connect/update totals, then sync that data back and forth, with not a lot of relationship/connections or transactional data.
Documentation is located:
https://docs.mongodb.com/master/core/transactions/#transacti...