Skip to content

Introduce generalized DataStore #544

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

Merged
merged 2 commits into from
May 21, 2025

Conversation

tnull
Copy link
Collaborator

@tnull tnull commented May 20, 2025

We already have a 'store' pattern in a few places in our codebase (peer store, payment store), and for #425 we're about to add yet another one. To at least somewhat DRY up the storage logic, we here introduce a generalized DataStore and migrate our PaymentStore to it. This is a prefactor to #425.

(cc @moisesPompilio)

@tnull tnull requested a review from jkczyz May 20, 2025 14:39
@ldk-reviews-bot
Copy link

ldk-reviews-bot commented May 20, 2025

👋 Thanks for assigning @jkczyz as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

Comment on lines +70 to +71
self.persist(&object)?;
let updated = locked_objects.insert(object.id(), object).is_some();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the order matter here? The opposite order is used in insert_or_update, so there we could have the object in memory but fail persisting.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this one used to be the other way around, but I changed it here (actually should be the only behavioral diff I snuck in, IIRC), exactly because it would be preferable to not update the in-memory version if persistence failed. However, for insert_or_update/update we won't know whether the update is necessary at all until StorableObject::update returns, which is why we unfortunately can't first persist.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For insert_or_update/update, it seems we log an error but continue. I suppose this predates the PR, but I wonder if we should do something else like have a queue of ids that still need persistence. Though if we eventually crash that information would be loss. Maybe this is more of a storage implementation concern.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we could do that eventually, although it probably would somehow need to fit into a "halt everything on (remote) persistence failure, and resume/restart once we reestablish connectivity" scheme.

@tnull tnull force-pushed the 2025-05-generalized-data-store branch from f29bdd3 to 6fa3502 Compare May 21, 2025 07:44
@tnull tnull requested a review from jkczyz May 21, 2025 07:44
Copy link
Contributor

@jkczyz jkczyz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM after squash.

Comment on lines +70 to +71
self.persist(&object)?;
let updated = locked_objects.insert(object.id(), object).is_some();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For insert_or_update/update, it seems we log an error but continue. I suppose this predates the PR, but I wonder if we should do something else like have a queue of ids that still need persistence. Though if we eventually crash that information would be loss. Maybe this is more of a storage implementation concern.

@tnull tnull force-pushed the 2025-05-generalized-data-store branch from 6fa3502 to 0561bc4 Compare May 21, 2025 17:45
@tnull
Copy link
Collaborator Author

tnull commented May 21, 2025

LGTM after squash.

Squashed without further changes.

tnull added 2 commits May 21, 2025 19:46
We increasingly feature different data stores that essentially do the
same thing, mod different data types. Here we add a generalized
`DataStore` that will be used to DRY up our logic.
.. we utilize the just-introduced generalized `DataStore` for our `PaymentStore`.
@tnull tnull force-pushed the 2025-05-generalized-data-store branch from 0561bc4 to 75aa069 Compare May 21, 2025 17:46
Copy link
Contributor

@jkczyz jkczyz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if CI failure is flakiness.

@tnull
Copy link
Collaborator Author

tnull commented May 21, 2025

Not sure if CI failure is flakiness.

Should be, I re-ran CI, will merge if it passes.

@tnull tnull merged commit 9151340 into lightningdevkit:main May 21, 2025
23 of 42 checks passed
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

Successfully merging this pull request may close these issues.

3 participants