-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Add a notion of lease in journaling #4939
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
base: main
Are you sure you want to change the base?
Conversation
| .await | ||
| { | ||
| tracing::error!( | ||
| "Failed to renew lease for UUID {uuid} and root key {root_key_owned:?}: {err}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: discard lease
| let (applied,) = row?; | ||
| if !applied { | ||
| // Delete failed - UUID doesn't match or row doesn't exist | ||
| tracing::warn!("Failed to discard lease"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: better message
|
|
||
| // Check if the LWT was applied | ||
| let rows = result.into_rows_result()?; | ||
| let mut rows = rows.rows::<(bool,)>()?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure about this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment:
- To make the examples compile under wasm32, the best is to make journaling, lru and the like not available in wasm32, where anyway they are not used.
- After those corrections, the DynamoDB end-to-end test fail randomly and the ScyllaDB test fail due to syntax error in the request.
- The
obtain_leaseis returning aResult<Result<_,_>,_>. Such constructions were previously proposed and refused forlinera-storagein favor of returning aResult<Option<_>,_>. I am find with doing such a construction, but better be clear about that. - To put the data in the journaling seems preposterous. Why not instead create a
LeaseDatabase? That seems cleaner. - To have the
tokio::spawninopen_exclusivewhich is not async is a break with previous practice. Could we instead have a boolean likeneed_leasein the store and whenever we need a database access we set it up. That is the lease is obtained at the first time we do an access. - Independent of this PR, we have in journaling.rs the entry
Journal = 1,which is contrary to our practices. - In journaling, the database error (pattern "Err(err)" is simply eaten instead of being propagated upstream with ?.
- The uuid in journaling.rs is a random number. Why not instead put the Thread ID? Isn't what we are really after.
- Both for DynamoDB and ScyllaDB, we are going to implement the lease with a key/value. Whjy not use the existing system. Adding more attributes (in DynamoDB) and keys (in ScyllaDB) seems like a waste. If it were up to me, I would write a single key
[255]and the value would be the thread-id and the end-time. - The
open_exclusiveis doing the job of spanning the thread. But the threads that does the cancellation token is done in the same thread that creates it.
Why not create a special (key, value), never deletes it.
- If absent, create it with (thread_id, duration).
- If present, if same thread_id, go ahead, if not, check the duration.
Do that check at the first access of an async operation in a LeaseDatabase connector.
yes
yeah claude must have hallucinated some of the DB queries
I'm not seeing which
We can discuss but reusing
unrelated and not changeable without migration
probably intended
The thread ID is not stable for a given root key. We could certainly add more information in addition to the UUID.
This won't allow the atomic test-and-update, which is what this PR is about.
so what? define "thread"
not sure where you're going with this |
Motivation
Prevent DB corruption
Proposal
TODO:
USING TTLTest Plan
CI + TBD
Release Plan
testnetbranch, then