database - Identical messages committed during a network partition -
i'm working on distributed database. i'm in situation where, during healing of partition (nodes beginning recognize ones split from) 2 different clients try , commit compare-and-set of 3 4, , both successful. logically, should not possible, i'm curious if there functional problem both returning successful. both clients correctly believe final state is, , command sent out successful. can't think of serious problems. there any?
the "standard" definition of cas (to extent there such thing?) guarantees @ 1 writer see successful response particular transition. couple examples depend on guarantee:
// generating unique id while (true) { unique_id = read(key) if (compare_and_set(key, unique_id, unique_id + 1)) { return unique_id } }
if 2 clients both read 3
, execute compare_and_set(key, 3, 4)
, they'll both think they've "claimed" 3 unique id , may end colliding down road.
// distributed leases/leader election while (true) { locked_until = read(key) if (locked_until < now()) { if (compare_and_set(key, locked_until, now() + ten_minutes)) { // i'm leader ~10 minutes. return; } } sleep(ten_minutes) }
similar problem here: if 2 clients see lock available , both cas acquire it, they'll both believe leader @ same time.
Comments
Post a Comment