go-morph / morph

Other
18 stars 1 forks source link

MM-41151: Do not use advisory locks if driver implements Lockable #35

Closed agnivade closed 2 years ago

agnivade commented 2 years ago

If a driver implements the Lockable interface, then we already use a manual table lock and hold it until all the migrations are over. So there's no need to additionally acquire advisory locks. They are just redundant.

Therefore, we maintain two modes of operation. Either a driver implements Lockable, in which case we avoid advisory locks. Or a driver does not do that, in which case we do use advisory locks to do the locking for us.

It is up to the driver implementor to do as they wish.

There are still some things to sort out from a driver perspective because logically speaking, we should just remove the advisory lock code. But then, we break the driver.Driver interface.

Later, one of the things that we can do is compose interfaces into larger ones. We can keep driver.Driver with just the basic one, and compose a larger one with driver.Locker and call it driver.DriveLocker or something like that, and then decide whether to call the global lock or advisory locks from the code.

https://mattermost.atlassian.net/browse/MM-41151

agnivade commented 2 years ago

cc @streamer45 (pinging you because I cannot assign you as reviewer directly without you having interacted in this repo :man_shrugging: )