Distributed locking, between two containers?

#1

Hi!

Topic: Distributed locking, between two containers? k8s.
Can such be done with help of CockroachDB?

I have understood that CockroachDB does not need locks: all DB operations are “locked” by other means.

We have different solution alternatives, but above one would help in one of those.
We could simply insert “lock” row to DB table which has unique index, in CockroachDB, but such row would need to be also cleaned up in case of problems.

Distributed locks can be achieved by other means also.

(Tim O'Brien) #2

@roachman can you tell us a bit more about what you have in mind? I’m not sure why you’d want to intentionally lock the database when it’s designed to ensure serializability.

#3

Actually golang-migrate exists for cockroachdb already.
So, I suppose / hope that the locking works with that. Lock table is mentioned on following source code page:

#4

Hi!

We have e.g. two containers which would do same schema update/upgrade, in upgrade of an app.
(One alternative among others.)
We want that only one of those containers does the upgrade. One way to achieve it, is by a “distributed lock”. I know there are other alternatives also, but I am interested about this one also.

“db-migrate” schema upgrade tool (golang) seems to make a “lock” with help of a “lock table” (postgresql part?). Maybe that might work when using CockroachDB , I would need to check in more detail.