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

Improve the lock interface to better suit distributed locks #1111

Open
Acconut opened this issue Apr 15, 2024 · 0 comments
Open

Improve the lock interface to better suit distributed locks #1111

Acconut opened this issue Apr 15, 2024 · 0 comments
Assignees
Milestone

Comments

@Acconut
Copy link
Member

Acconut commented Apr 15, 2024

The current lock inferface was primarily inspired by in-memory mutexes, where one can assume that an acquired mutex is valid until it is released again. These assumption do not hold up for distributed lock mechanisms and we should adjust the lock interface to accommodate those:

  • Distributed locks often provide leases instead of mutexes. A lease has a specific lifetime, after which it expires and the lease is available to be grabbed by another entity. If the owner wants to continue holding exclusive access they have to extend the lease. This ensures that when the owning process dies, the lease is not locked forever, but is released after a given fixed duration. This means that our new inferface should
    • expose a method for extending the lease. This method is then regularly called by the tusd handler to ensure that the lease is extended while the request is being handled. This should be done by the request handler to ensure that the lease is not extended whenever the request handling is aborted or crashes.
    • return a context that is valid as long as a valid lease is held. If we are not able to extend the lease, the context should be cancelled as we cannot ensure anymore that we have exclusive access and any access must be immediately interrupted.
  • The lock interface incorporates a feature for requesting releases for locks. However, this naming is not entirely correct because it requests the controlled abortion of the handling of another request. The ending of that will then cause the lock to be released. On a technical level, we could separate the locking interface from this messaging interface to make the system more composable. We could even think about making the messaging system more capable if there are use cases where tusd instances should communicate with each other.
@Acconut Acconut self-assigned this Apr 15, 2024
@Acconut Acconut added this to the v3 milestone Sep 18, 2024
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

1 participant