globalsign / mgo

The MongoDB driver for Go
Other
1.97k stars 230 forks source link

Add ACID support #177

Closed ninedraft closed 10 months ago

ninedraft commented 6 years ago

Multi doc ACID transactions are part of mongo now! Please, add at least basic support. If any help is a need, I'm ready for the assistance.

domodwyer commented 6 years ago

Hi @ninedraft

This involves a lot of work before transaction support can be added. Assuming the OP_MSG wire protocol introduced in 3.6 is required, a minimum of:

The actual driver specification for transactions hasn't been published yet.

@feliixx (thanks!) did a fantastic job and all the really tricky bits are already done, but there's still a lot left! While 4.0 support isn't a priority for us internally, we are always open to PRs and will happily maintain and test the driver additions for stability, etc.

Dom

duskglow commented 6 years ago

Hi,

I've added some rudimentary 4.0-style transaction support. I'll be sending a pull request shortly. I don't pretend it won't need a little more work, but the actual base support was pretty easy. I didn't use the "txn" library, I just bolted it right into the main code, but in a backward-compatible fashion.

I don't have tests or anything like that, though. Should I just send the PR and see what happens?

duskglow commented 6 years ago

You can see a preview of what we've done at https://github.com/homedepot/mgo . There's also some basic documentation on how to use it. We need to add tests and other things so it'll be a bit before I can do a pull request, but please feel free to take a look over the changes and provide feedback if you're so inclined.

The long and short is: we created a new transaction object, and added transaction support in the session object. So now you just create a transaction object based on the session and use that for the transactions. There's some cleanup and a few changes that we need to make before it's "ready for prime time", but you can get the gist from that. Please let us know if you have feedback, we can devote a little time to addressing concerns to make it ready for the wider community.

If you want to do a "glide get" on our repo, feel free, but it's a moving target right now, so I don't promise it will be stable for the short term.