Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document limitations of locks issued #62

Open
tobyhei opened this issue Sep 14, 2021 · 5 comments
Open

Document limitations of locks issued #62

tobyhei opened this issue Sep 14, 2021 · 5 comments

Comments

@tobyhei
Copy link

tobyhei commented Sep 14, 2021

The documentation states that e.g if used for leader election the lock can be relied upon to ensure there is only one leader.

As per https://martin.kleppmann.com/2016/02/08/how-to-do-distributed-locking.html which is referenced in Amazons own library https://aws.amazon.com/builders-library/leader-election-in-distributed-systems/ this isn’t correct without a fence using a monotonic version number.

This library seems to only use a UUID for the record version meaning clients can’t implement a fence correctly.

Could the documentation either mention thIs limitation or mention how a fence can be implemented by clients if I’ve missed something.

@tobyhei
Copy link
Author

tobyhei commented Sep 16, 2021

I now see this has already been discussed, but it doesn’t seem like a resolution was reached and instead the issue was locked. #1

@jpo-tu
Copy link

jpo-tu commented Jul 11, 2022

https://github.com/awslabs deleted a comment from fernomac [on Oct 12, 2017]

Ya what happened in that thread for it to just go dead.

@jpo-tu
Copy link

jpo-tu commented Jul 11, 2022

referenced in Amazons own library https://aws.amazon.com/builders-library/leader-election-in-distributed-systems/

The paper even recommends to not do what this library does: "Avoid heartbeating leases in a background thread" yet that's what createHeartbeatBackgroundThread is for.

@suitianshiwx
Copy link

The documentation states that e.g if used for leader election the lock can be relied upon to ensure there is only one leader.

As per https://martin.kleppmann.com/2016/02/08/how-to-do-distributed-locking.html which is referenced in Amazons own library https://aws.amazon.com/builders-library/leader-election-in-distributed-systems/ this isn’t correct without a fence using a monotonic version number.

This library seems to only use a UUID for the record version meaning clients can’t implement a fence correctly.

Could the documentation either mention thIs limitation or mention how a fence can be implemented by clients if I’ve missed something.

Yeah, this lock client actually targets "efficiency" instead of "correctness". if during the processing the lock expires, there's no way to check that. Even with the "fencing token" mentioned by Martin, there can still be race conditions because "validating the token" and "take the writes" are not atomic operations and don't happen instantaneously.

@suitianshiwx
Copy link

There's a way to ensure correctness, but the supported use case is very limited (e.g. by relying on a CAS provided by db system, can work iff lock and resource access are in the same table/row)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants