News for hackers. Stuff that matters.
Re:Jepsen: MongoDB 4.2.6 by inglor on Sunday May 24, 2020 @09:27AM (#23291346)
I also want to point their Node.js transactions API is wrong and looks like they have no idea how promises or async code work in JS.

In mongo, you have a `withTransaction(fn)` helper that passes a session parameter. Mongo can call this function mutliple times with the same session object.

This means that if you have an async function with reference to a session and a transaction gets retried - you very often get "part of one attempt + some parts of another" committed.

We had to write a ton of logic around their poor implementation and I was shocked to see the code underneath.

It was just such a stark contrast to products that I worked with before that generally "just worked" like postgres, elasticsearch or redis. Even tools people joke about a lot like mysql never gave me this sort of data corruption.

Edit: I was kind of angry when writing this so I didn't provide a source and I'm a bit surprised this go so many upvotes without a source (I guess this community is more trusting than I assumed :] ). Anyway for good measure and to behave the way I'd like others to when making such accusations here is where they pass the same session object to the transacton https://github.com/mongodb/node-mongodb-native/blob/e5b762c6... (follow from withTransaction in that file) - I can add examples of code easily introducing the above mentioned bug if people are interested.

Re:Jepsen: MongoDB 4.2.6 by inglor on Sunday May 24, 2020 @09:29AM (#23291361)
If you work for Mongo and are reading this. Please just fix it. I don't need to win and I don't care about being "right".

I just don't want to be called to the office on a weekend anymore for this sort of BS.

Production incidents with MongoDB last year: 15 Production instances with redis, elasticsearch and mysql combined last year: 2 (and with much less severity)

Edit: just to add: I didn't pick Mongo, I was just the engineer called to clean that mess. I created enough of my own messes to not resent the person who made that shot for it. We are constantly on the verge of rewriting the MongoDB stuff since a database that small (~250GB) should really not have these many issues (In previous workplaces I ran ~10TB PostgreSQL deployments with much more complicated schemas and queries with far fewer issues). It's also expensive and support at Mongo Atlas hasn't been great (we should probably self host but I am not used to small databases being so problematic)

Re:Jepsen: MongoDB 4.2.6 by brianwawok on Sunday May 24, 2020 @09:48AM (#23291486)
This is why most of us don’t use mongo in production. It’s just not worth it. Postgres is a tank and supports Json when you really need it.
Re:Jepsen: MongoDB 4.2.6 by hetspookjee on Sunday May 24, 2020 @10:42AM (#23291828)
The Guardian posted quite a nice blog in 2018 about the switch to Postgres from MongoDB. Especially interesting because they intended to use Postgres as replacement document storage: Here's the link https://www.theguardian.com/info/2018/nov/30/bye-bye-mongo-h...
Re:Jepsen: MongoDB 4.2.6 by guanzo on Sunday May 24, 2020 @12:56PM (#23292809)
> Automatically generating database indexes on application startup is probably a bad idea.

aw crap. oh well it probably doesn't matter for my small-ish application.

Re:Jepsen: MongoDB 4.2.6 by Quekid5 on Sunday May 24, 2020 @03:09PM (#23293820)
I was actually amazed that a big CMS/E-commerce vendor proudly proclaimed in a sales meeting that they were on MongoDB.

I suppose salespeople probably aren't into the nitty-gritty, but their tech people should have warned them about this. Maybe they were just trying to pull our collective leg, but I suppose that why I was at that meeting.

It was obviously an instant 'No'.

Re:Jepsen: MongoDB 4.2.6 by leviathant on Sunday May 24, 2020 @06:11PM (#23295308)
There aren't a lot of CMS/Ecommerce vendors that sit on MongoDB, so maybe we were in a meeting together!

Even if we weren't - as a sales engineer on a large CMS/ECommerce platform with merchants running $150M+ in annual revenue, with an average client retention of seven years, and two decades of agency experience behind the decisions around building that platform, if you instantly said no just because of MongoDB, maybe you don't know as much about MongoDB as you think you do.

I came from a SQL background myself, and had reservations based on all the things I'd read about MongoDB as we decided to build a platform after doing things bespoke for two decades, but time has proven our architecture choices out. It's easy to be proud of something that works well.

Re:Jepsen: MongoDB 4.2.6 by arp242 on Sunday May 24, 2020 @12:38PM (#23292657)
I didn't pick Mongo, I was just the engineer called to clean that mess.

My only experience with MongoDB is being "the engineer called to clean the mess". I'm sure you can effectively use MongoDB in production if you're knowledgable and careful, but most people aren't and they shouldn't have to know the detailed inner working to not create a mess.

Re:Jepsen: MongoDB 4.2.6 by goatinaboat on Sunday May 24, 2020 @03:17PM (#23293881)
My only experience with MongoDB is being "the engineer called to clean the mess".

It’s always the same

1. Newbie webdev (aren’t they all) uses MongoDB because it’s easy to use according to blogs and twitter

2. Somehow it makes it into production

3. A dozen experienced engineers spend years trying to keep it running

Re:Jepsen: MongoDB 4.2.6 by sophiebits on Sunday May 24, 2020 @11:59PM (#23297644)
No, not all web devs are “newbies”.
Re:Jepsen: MongoDB 4.2.6 by xpe on Monday May 25, 2020 @12:39PM (#23302618)
Please remember to search for a charitable interpretation of what someone writes, per the HN guidelines [1]:

> Please respond to the strongest plausible interpretation of what someone says, not a weaker one that's easier to criticize. Assume good faith.

[1]: https://news.ycombinator.com/newsguidelines.html

In this case, the parent commenter probably meant that "newbie web developers" are likely to choose MongoDB. Of course, web developers have a range of experience, some new, some seasoned.

Regarding your comment, I am reminded of a pattern in online behavior over time: people seem to take offense more easily. Please take a look at https://www.psychologytoday.com/us/blog/how-do-life/201410/t... to understand what I mean.

Re:Jepsen: MongoDB 4.2.6 by xpe on Monday May 25, 2020 @11:33PM (#23307160)
Caveat: this is a meta-comment about voting, not a complaint about how people upvoted or downvoted the parent comment. (My motivations are explained at the very bottom).

Based on seeing how comments like this may get interpreted, as well as broader thinking about online communication, I think HN should consider a more nuanced system of comment feedback mechanisms.

I don't have a particular plan finalized, but I would like to see HN provide feedback on different aspects of the comment. Below are some important aspects:

To what degree does the reader / voter... *

1. agree/disagee with the comment?

2. find the comment relevant / irrelevant to the topic as a whole?

3. find the comment is situated in the correct / incorrect location in the thread? (e.g. responding to the parent comment or not) 4. find the comment interesting / uninteresting?

5. think the comment adds to a diversity of perspectives?

6. find the comment clear / unclear?

7. think the comment aligns / (does not align) with the HN Guidelines: https://news.ycombinator.com/newsguidelines.html

8. find the comment welcoming / offensive?

* When I write '/' above, I intend it to be a continuum; e.g. hot/cold means "in the continuum between hot and cold).

Additionally, being able to give feedback in a more granular fashion could be of use. For example, in my comment above, I would not be surprised if a significant number of people were bothered/offended by my commentary that people seem to be taking offense more easily. Some would call this ironic -- I wouldn't -- I think it gives more data to prove the point.

Motivations: my goal here is not to gain or lose karma -- I care very little about karma here, precisely because it is so muddled and varied from person to person -- as long as I have enough to participate fully. My goal is to learn and play a small part in fostering awareness and community, while hopefully to motivating others to reflect on their impact on the community here.

Re:Jepsen: MongoDB 4.2.6 by xpe on Monday May 25, 2020 @11:41PM (#23307193)
Wow, I re-read the grandparent comment noticed it said:

> "Newbie webdev (aren’t they all) uses MongoDB because it’s easy to use according to blogs and twitter"

I'm not sure if I completely missed the "aren't they all" part or if the comment got edited.*

So, clearly, in response to "aren't they all", the response by sophiebits above makes complete sense.

* This makes me wonder, is a comment locked for editing once a reply gets added?

Re:Jepsen: MongoDB 4.2.6 by takeda on Sunday May 24, 2020 @01:27PM (#23293053)
MySQL is less of a joke than MongoDB is. They similarly started by someone who didn't know anything about databases and learned about them on the go. Actually both of them started as much faster alternatives to other databases, both ended up having complete rewrite of its engine written by someone from outside that knew their stuff. MySQL ISAM then MyISAM and then InnoDB (written by an outsider). Similarly MongoDB got a WiredTiger written.

The thing is that MySQL is older so it went through all of it earlier, but it still suffers from poor decisions from the past. This is contrasting with PostgreSQL, where correctness and reliability was #1 from the beginning. It started as an awfully slow database, but performance for improved and we now have correct, reliable and fast database.

Re:Jepsen: MongoDB 4.2.6 by berns on Sunday May 24, 2020 @03:10PM (#23293831)
MySQL is no joke, nothing is perfect and Postgresql is not 100% reliable. Remember:

Transaction ID wraparound: https://twitter.com/bcantrill/status/1110647418008133632

Incorrect use of fsync: https://news.ycombinator.com/item?id=19119991

Re:Jepsen: MongoDB 4.2.6 by goatinaboat on Sunday May 24, 2020 @03:36PM (#23294031)
MySQL is no joke

If you were around back in the day you will remember the MySQL team claiming that no one needed transactions or referential integrity, that you should just do it yourself in the application...

Re:Jepsen: MongoDB 4.2.6 by edw on Sunday May 24, 2020 @06:14PM (#23295351)
MySQL's rise IMO cannot be considered without also looking at the rise of Ruby on Rails and other CRUD-optimized platforms and frameworks. Also ORMs. These things denigrated the idea of using an RDBMS as anything but a dumb table store. Features like stored procedures and views were seen as pointless. MySQL was the perfect database for people who had no respect for databases.
Re:Jepsen: MongoDB 4.2.6 by bri3d on Sunday May 24, 2020 @10:46PM (#23297246)
I agree that the rise of MySQL is combined with using RDBMS as a table store rather than a relational database, but I am not positive that this was driven by RoR and ORMs. Every large-scale system I have worked with that utilizes MySQL (and I'm on at least my third in a row of these systems, sadly!) is/was driven by application-logic database utilization via the "FriendFeed model" - that is, a big fat ID->Document Blob table for persistence and breakout tables for indexing.

ORMs and ActiveRecord in particular encourage, to some extent, the use of a RDBMS, even if they didn't get to take advantage of them well for a long time - for example, in RoR "has_one / has_many" for foreign-key relationship, .joins(:field_name) for, well, joins, and so on.

Re:Jepsen: MongoDB 4.2.6 by edw on Monday May 25, 2020 @09:46AM (#23301035)
Perhaps. Something happened between those first-generation web sites where you were writing SQL by hand -- so you could just as easily be writing (injection-attack-prone) queries that made use of stored procedures etc -- and today.

A big reason I called out RoR is that back in '04-05 I was railing against its default use of plural table names, and DHH on IRC recommended I shut up and just flip the configuration switch and turn off the feature, but of course when I did that all sorts of latent bugs were exposed.

RoR was the beginning of hipster "coding" and I therefore blame it for everything.

I'm wasn't previously familiar with the FriendFeed approach to database (ab)use. I paid about as much attention to it as I did to MySpace back in the day -- nearly zilch -- so its etc innards are doubly obscure to me.

Re:Jepsen: MongoDB 4.2.6 by Xorlev on Sunday May 24, 2020 @08:13PM (#23296221)
MySQL was already ridiculously popular from use in PHP/MySQL applications well before Rails was popular. That said, I generally agree with your statement:

> MySQL was the perfect database for people who had no respect for databases.

Re:Jepsen: MongoDB 4.2.6 by bearcherian on Monday May 25, 2020 @12:16AM (#23297743)
The good old LAMP stack
Re:Jepsen: MongoDB 4.2.6 by twic on Sunday May 24, 2020 @03:43PM (#23294105)
Does MySQL support check constraints yet?
Re:Jepsen: MongoDB 4.2.6 by dnissley on Sunday May 24, 2020 @06:13PM (#23295339)
It does finally! In 8.0.16+
Re:Jepsen: MongoDB 4.2.6 by beatrobot on Sunday May 24, 2020 @04:48PM (#23294555)
And still no transactional DDL in MySQL
Re:Jepsen: MongoDB 4.2.6 by mathnode on Sunday May 24, 2020 @06:18PM (#23295376)
No, but it does support online DDL for some operations in InnoDB.

Very few database systems support online DDL, which unlike a transaction, does not require undo or rollback resources. Of course one must have a rollback procedure if something fails, but you need one for transactions too, just in case.

An online rollback is far lest costly than a transactional rollback, because and online rollback is just undoing what you did. Added a column you didn't want in one query? Remove it again in another, very quickly.

TokuDB (a mysql/mariadb storage engine) supported all DDL as an online operation. But percona killed it in favour of TokuMX, the MongoDB equivalent.

TokuMX has no upgrade path to wired tiger, only one major customer at Percona (I can't say who it is) and no engineers.

Any kind of DDL is tricky and requires users to RTFM for the intricacies of their chosen database. One size rarely fits all.

Re:Jepsen: MongoDB 4.2.6 by vlasky on Monday May 25, 2020 @05:52AM (#23299573)
TokuDB is a great storage engine! Online DDL and fast compression are a winning combo. We use it for all our big MySQL tables. It is still available in MySQL 8.0.

I really wish Percona would reconsider their decision to deprecate it.

After Percona took over TokuDB's creator TokuTek, they wasted so much of their development time and money on TokuMX (Percona's fractal tree-enabled MongoDB server) only to abandon it in 2017.

That money would have been better spent on TokuDB development to allow it to match the features present in InnoDB like generated columns, spatial indexing, fulltext Indexes and Galera.

TokuDB still has many users and MyRocks is just no substitute.

Re:Jepsen: MongoDB 4.2.6 by jfkebwjsbx on Sunday May 24, 2020 @10:59AM (#23291949)
> Even tools people joke about a lot like mysql never gave me this sort of data corruption.

People rightfully joked about MySQL when they had the non-ACID engine.

Same for MongoDB. A database that loses data when properly used is a joke.

Yes, there are use cases out there for fast non-guaranteed writes. No, 99% of companies don’t have them.

Re:Jepsen: MongoDB 4.2.6 by Something1234 on Sunday May 24, 2020 @01:31PM (#23293080)
Can you name a use case for a fast non guaranteed write?
Re:Jepsen: MongoDB 4.2.6 by throwaway744678 on Sunday May 24, 2020 @01:51PM (#23293205)
Analytics: you don't want to slow down your app, and you don't care if you lose a few records in the process.
Re:Jepsen: MongoDB 4.2.6 by zbentley on Sunday May 24, 2020 @03:26PM (#23293945)
Importantly, in analytics workloads, it is very important to know roughly how many writes aren't making it. Otherwise your analytics system sucks.
Re:Jepsen: MongoDB 4.2.6 by rocho on Sunday May 24, 2020 @05:39PM (#23295057)
Interesting. How would one know that?
Re:Jepsen: MongoDB 4.2.6 by zbentley on Sunday May 24, 2020 @06:13PM (#23295338)
Good question. You'd need some accurate-enough data source telling you about failed writes. Which eventually comes back around to needing a consistent database and indications of client disconnects.
Re:Jepsen: MongoDB 4.2.6 by staticautomatic on Tuesday May 26, 2020 @02:18AM (#23307989)
With a huge amount of data (as I've heard analytics is), could you take a sampling approach where you log every n transaction and only check those against the DB?
Re:Jepsen: MongoDB 4.2.6 by twic on Sunday May 24, 2020 @03:48PM (#23294144)
Caches. If you lose a write, you just get a cache miss.

Periodic snapshots of state held elsewhere. If you lose a write, you just get stale data until the next update.

Firm realtime work. If you lose a write, that sucks, but a slow write sucks just as much.

Re:Jepsen: MongoDB 4.2.6 by Jweb_Guru on Sunday May 24, 2020 @01:42PM (#23293156)
Sure. Data that people don't care about enough to be worried about losing--for example, time series data from an unimportant remote sensor. Should this data be recorded at all? Maybe not, but if should then a best-effort recording may be fine. It may even be all that's possible.
Re:Jepsen: MongoDB 4.2.6 by mbreese on Sunday May 24, 2020 @01:53PM (#23293214)
I wouldn’t go as far as to say an “unimportant” remote sensor... but I think you’re correct in spirit.

I could think of an instance where you’d like to log data, but the occasional datapoint being missing wouldn’t be terrible. Maybe something like a temperature monitor — you’d like to have a record of the temperature by the minute, but if a few records dropped out, you’d be able to guess the missing values from context. Something like the data monitoring equivalent of UDP vs TCP.

Re:Jepsen: MongoDB 4.2.6 by why-el on Sunday May 24, 2020 @03:00PM (#23293750)
Even more elementary that sibling comments, this also happens in gaming all the time. You are recording live results, say in Fifa, but if you unplug your device, your results are gone, since they were memory only. The game simply cannot afford to write to disk, the write is "non guaranteed" in the true sense of the word, but it is fast.

You then "checkpoint" when the game is over.

You might dissent that is not a "non-guaranted" write, because in fact the write did occur, but I simply want to allude to the concept of a "non-secured" write, in that it vanished without an fsync.

Re:Jepsen: MongoDB 4.2.6 by jfkebwjsbx on Sunday May 24, 2020 @03:09PM (#23293821)
The number of likes in a given post in your favorite $social-network-of-the-year.
Re:Jepsen: MongoDB 4.2.6 by squiggleblaz on Monday May 25, 2020 @06:27AM (#23299744)
Since that number may well already be approximate if it's recorded in a hyperlog log.
Re:Jepsen: MongoDB 4.2.6 by threeseed on Sunday May 24, 2020 @06:11PM (#23295310)
Telemetry.

I work for a telco where we log large amounts of network requests using MongoDB.

Re:Jepsen: MongoDB 4.2.6 by lossolo on Sunday May 24, 2020 @11:23AM (#23292133)
When I was evaluating MongoDb couple of years ago (around the time they were switching to WiredTiger engine), I've found memory leak in their Node.js client on day one, I've submitted a ticket on their Jira and the same time I had a look at other issues they had there. I saw there memory leak after memory leak, memory corruption everywhere, data disappearing without any reason, segfaults etc. After that MongoDB was dropped as a candidate for a DB in project I was working on, we went with Postgres and never regretted it.
Re:Jepsen: MongoDB 4.2.6 by xeromal on Sunday May 24, 2020 @01:57PM (#23293245)
I just want remind people that this video exists.

https://www.youtube.com/watch?v=b2F-DItXtZs

Re:Jepsen: MongoDB 4.2.6 by sorokod on Monday May 25, 2020 @12:12PM (#23302439)
Well, does dev/null supports sharding?
Re:Jepsen: MongoDB 4.2.6 by hintymad on Sunday May 24, 2020 @01:41PM (#23293147)
Just curious, what was the reason that your team decided to work around the problem instead of migrating away from MongoDB?
Re:Jepsen: MongoDB 4.2.6 by capableweb on Sunday May 24, 2020 @01:47PM (#23293183)
Not the author but done similar things (patching something rather than migrating away from it). Usually it's way more work to migrate away than just patching it again to fit your use-case. Once you find yourself having to patch it too often, you start thinking about migrating away. Then the research slowly begins ad-hoc until it hits "seems we need to migrate away now, otherwise we're spending too much time working around something / fixing their broken shit", that's when you sit down and decide to migrate away from it.

Also would depend on how long time you think the application will be around. You're building an MVP to evaluate something? Just hack together whatever will work (then throw away). You're maintain software for a library/archive that will most likely stick around for a long time, even if they say it's just temporary? Do decisions that will help in the future, always.

Re:Jepsen: MongoDB 4.2.6 by inglor on Sunday May 24, 2020 @02:13PM (#23293372)
We have a complicated system and migration is ~3 months we won't be shipping features.

We have a roadmap we need to meet and so far we have been trying to spill money on it rather than developers (paying mongo atlas) and adding features incrementally as Mongo gets them (like transactions).

If this wasn't a startup we would probably rewrite.

Re:Jepsen: MongoDB 4.2.6 by hodgesrm on Sunday May 24, 2020 @11:12AM (#23292043)
> Even tools people joke about a lot like mysql never gave me this sort of data corruption.

That's about a decade out of date at this point. MySQL/InnoDB is the standard table engine and corruption is exceedingly rare. As of 2014, when I last directly worked on MySQL prod systems, there was no practical difference from PostgreSQL in terms of transactional guarantees. That includes APIs like JDBC which we used for billions of transactions.

Re:Jepsen: MongoDB 4.2.6 by arp242 on Sunday May 24, 2020 @12:59PM (#23292827)
The biggest issue with MySQL/MariaDB isn't so much data corruption at the InnoDB level but stuff like:

  MariaDB [test]> create table test ( i int );
  Query OK, 0 rows affected (0.06 sec)
  
  MariaDB [test]> insert into test values (''), ('xxx');
  Query OK, 2 row affected, 2 warning (0.01 sec)
  
  MariaDB [test]> select * from test;
  +------+
  | i    |
  +------+
  |    0 |
  |    0 |
  +------+
  2 row in set (0.01 sec)
There's a bunch of other similar caveats as well, and this can really take you by surprise. I've seen it introduce data integrity issues more than once.

That's a new MariaDB 15.1 with the default settings I just installed the other day to test some WordPress stuff. I know there are warnings, and that you can configure this by adding STRICT_ALL_TABLES to SQL_MODE, but IMO it's a dangerous default.

This is also an issue with using MongoDB as a generic database: every time I've seen it used there were these kind of data integrity issues: sometimes minor, sometimes brining everything down. Jepsen reports aside, this alone should make people double-check if they really want or need MongoDB, because turns out that most of the time you don't really want this.

Re:Jepsen: MongoDB 4.2.6 by mathnode on Sunday May 24, 2020 @06:03PM (#23295252)
15.1 is not a version. Since MariaDB 10.2, this is not possible as strict_trans_tables is enabled by default in sql_mode.
Re:Jepsen: MongoDB 4.2.6 by morelisp on Sunday May 24, 2020 @12:44PM (#23292718)
MySQL still has no transactional DDL (and I think still even autocommits if you try). This is a major difference from Postgres which I believe supports everything short of dropping tables.
Re:Jepsen: MongoDB 4.2.6 by yobert on Sunday May 24, 2020 @01:58PM (#23293247)
Every month, we do an external database import into our production PostgreSQL database. In a single transaction, we drop dozens of tables, create new ones with the same names, insert hundreds of thousands of rows, and recreate indexes, all in a single transaction. It works flawlessly.
Re:Jepsen: MongoDB 4.2.6 by vijaybritto on Monday May 25, 2020 @03:00AM (#23298714)
wow! have you tested for network errors in any of these steps? Will it rollback automatically if there are any errors?
Re:Jepsen: MongoDB 4.2.6 by sterwill on Monday May 25, 2020 @09:40AM (#23300962)
If it's in a transaction, it will do the same thing it would do for any failed transaction (roll it back). DDL isn't special.
Re:Jepsen: MongoDB 4.2.6 by takeda on Sunday May 24, 2020 @01:34PM (#23293098)
I wouldn't use that particular thing against MySQL. DDL normally supposed to be always outside of a transaction, it's just PostgreSQL feature that you can use them inside and be able to rollback. BTW I'm convinced you also can drop table within a transaction in PostgreSQL.
Re:Jepsen: MongoDB 4.2.6 by morelisp on Sunday May 24, 2020 @01:52PM (#23293213)
No, MySQL stands out here. Postgres, SQL Server, DB2, and Firebird all give at least some way to do some major DDL transactionally. Usability varies (e.g. Oracle supports a very specific kind of change that is not its normal DDL statements), but it's at least possible.

https://wiki.postgresql.org/wiki/Transactional_DDL_in_Postgr...

That MySQL autocommits is also even worse than just "doesn't support it."

Re:Jepsen: MongoDB 4.2.6 by dragonwriter on Sunday May 24, 2020 @02:09PM (#23293324)
> DDL normally supposed to be always outside of a transaction

A basic element of the relational model is that metadata is stored as relational data and that the same guarantees that apply to manipulating main data in the database apply to manipulating the schema metadata.

It's true that many real relational databases compromise on this element in various ways at times, but it is absolutely not the case that DDL “is supposed to be” non-transactional.

Re:Jepsen: MongoDB 4.2.6 by vorticalbox on Sunday May 24, 2020 @11:03AM (#23291982)
> Mongo can call this function multiple times with the same session object.

isn't that the point? you can use a session to do multi actions within that session.

Re:Jepsen: MongoDB 4.2.6 by inglor on Sunday May 24, 2020 @11:10AM (#23292027)
If you have code that looks like this:

    withTransaction(async session => {

      await Promise.all([someOp(sesson), 

      someOtherOp(session)]);

    });

Mongo may retry running it (calling the function again) if a "TransaientTransactionError" is raised (the transaction is retried from the client side rather than at the cluster).

However, when the driver calls your function again it doesn't invalidate the `session` object - so previous calls to the same function can make updates to the database.

Let's say `someOp` does something that causes the transaction to retry and `someOtherOp` is doing something non-mongo-related in the meantime (like pulling a value from redis). Now `someOtherOp` reached the mongo part of its code and it is executing it happily with the same session object (so operations succeed although they really shouldn't)

The point of transactions like you said is to perform multiple operations atomically and for them to happen "exactly once or not at all". With Mongo in practice it is very easy to get "Once and some leftovers from a previous attempt".

Re:Jepsen: MongoDB 4.2.6 by IgorPartola on Sunday May 24, 2020 @11:35AM (#23292234)
Sorry, I haven’t had my coffee yet. If I am reading this correctly, either someOp() or someOtherOp() may execute first, no? And if you introduce an external database, why do you expect Mongo to handle that rollback? Say someOtherOp() increments a Redis value by 1. If that part executed first since both are asynchronous here, what would a Mongo session have to do with it?

What exactly would invalidating that session object do here? And what would the session object do after it was invalidated?

Re:Jepsen: MongoDB 4.2.6 by waheoo on Sunday May 24, 2020 @11:47AM (#23292334)
It sounds like the old session object is reused and becomes live again or something.
Re:Jepsen: MongoDB 4.2.6 by bambataa on Sunday May 24, 2020 @11:40AM (#23292274)
Thanks for this explanation. So if I understand correctly, `someOp` has thrown an error but this doesn't affect `someOtherOp`? So `someOtherOp` will end up being called twice?
Re:Jepsen: MongoDB 4.2.6 by inglor on Sunday May 24, 2020 @12:02PM (#23292421)
Correct, the easy workaround is not to use that transaction API and write your own disposer instead of using withTransaction.
Re:Jepsen: MongoDB 4.2.6 by Namari on Sunday May 24, 2020 @02:03PM (#23293295)
I think this is the expected behaviour of the transaction but the problem comes from the fact you wrap all DB operation inside a Promise.all.

Because you wrap the DB operations inside a Promise.all, it means it will run them all BUT it will not revert them if one fails (it's not atomic, it just says that one has failed and you need to catch it), it will reject them but not revert them. (the CUD operation will already have changed the data) The problem I believe is the transaction is considering the Promise.all and not what's inside of it so it will run it again despite the fact that some have already succeeded earlier

I think you just have to resolve each of them outside a Promise.all. In your case because Promise.all has been rejected it will redo the transaction, therefor it will redo the one that have already worked in the first call.

I'm no expert but this is how I understand it.

Re:Jepsen: MongoDB 4.2.6 by fendy3002 on Sunday May 24, 2020 @07:41PM (#23295982)
Not op, I think what he means is the session, even when already failed once, can still be used (without error) in the next operation without being invalidated.

Without promise.all, I think it can be replicated like this:

    try{
      await someOp(session);
    catch { }
    await someOtherOp(session);
He expected what the session to be invalidated during someOtherOp.
Re:Jepsen: MongoDB 4.2.6 by inglor on Monday May 25, 2020 @04:56AM (#23299317)
That is correct and what I meant. Thanks, and there doesn't have to be a `try/catch` because it is possible to "fork" control with promises.

They implemented a "disposer" incorrectly (I added this to several other libraries and made a Q&A about it here https://stackoverflow.com/questions/28915677/what-is-the-pro... )

[dead]
Re:Jepsen: MongoDB 4.2.6 by couchand on Sunday May 24, 2020 @08:57PM (#23296563)
Please be civil.
Re:Jepsen: MongoDB 4.2.6 by inglor on Monday May 25, 2020 @05:32AM (#23299486)
I have found people to attack me when I make a technical criticism of technologies they like.

Am I expected to justify being able to code in HN? I could go on about being a maintainer of the two most promise libraries in npm (bluebird and Q), being node core, organizing promises sessions for APIs in Node core and having over 1000 answers about promises in SO.

I generally find that sort of "non-technical chat" boring compared to the technical stuff and appeal to authority kind of lame.

The only other person attacked in this issue is aphyr, so I believe I am in very good company in this particular instance.

Re:Jepsen: MongoDB 4.2.6 by g0ldenb0ugh on Sunday May 24, 2020 @09:12PM (#23296667)
> We had to write a ton of logic around their poor implementation and I was shocked to see the code underneath.

Just wondering, did you submit a bug report to them about this? If so, any response?

Re:Jepsen: MongoDB 4.2.6 by inglor on Monday May 25, 2020 @04:58AM (#23299327)
Yes, several times - we pay Mongo Atlas over $5000 per month.

We reported it immediately at the highest severity and we pay for the highest tier or support - we tried to collaborate as soon as possible. It sort of went "over their head".

Re:Jepsen: MongoDB 4.2.6 by g0ldenb0ugh on Monday May 25, 2020 @10:31AM (#23301488)
Can you link the JIRA ticket? I use the Node driver heavily and have contributed several PRs to it in the past, would be more than happy to fix this since it seems fairly bad.
Re:Jepsen: MongoDB 4.2.6 by inglor on Tuesday May 26, 2020 @05:46AM (#23309040)
Hi, I'm not sure where I'm supposed to look for JIRAs at but we discussed this with Mongo Atlas via several support tickets and channels.

For example at #00636235 "how to avoid TransientTransactionError".