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

fix: panic: Must deleted existing spendable note [broken, don't land] #5272

Closed
wants to merge 1 commit into from

Conversation

dpc
Copy link
Contributor

@dpc dpc commented May 12, 2024

Fix #5271

In one of the recent commits I've added an assertion to make sure a spendable note was actually always removed when we thought it was, as I was investigating a bug causing notes to be lost (#5195), and it seemed like a good idea.

Too bad it causing flakes now: #5271

So it looks like our reliance on retrying db conflicts (autocommit), leads to inability to assert basic expectations about database state, which seems terrible.

In PR I'm adding a little lock to prevent write-write conflicts in this area of the code, and I think it's worthwhile, just to be able to ensure database integrity.

Moreover, I realized that autocommit is probably a bad idea altogether.

Application typically require transaction conflict handling, because they are using shared databases. But with an embedded databases, there is no sharing with external entities so there always should be, or even must be a way to structure application and locking to avoid any conflicts, preventing db isolation level issues, inability to assert basic stuff, or just wasting time retrying things.

In one of the recent commits I've added an assertion to make sure a
spendable note was actually always removed when we thought it was,
as I was investigating a bug causing notes to be lost (fedimint#5195),
and it seemed like a good idea.

Too bad it causing flakes now: fedimint#5271

So it looks like our reliance on retrying db conflicts (`autocommit`),
leads to inability to assert basic expectations about database state,
which seems terrible.

In PR I'm adding a little lock to prevent write-write conflicts in this
area of the code, and I think it's worthwhile, just to be able to
ensure database integrity.

Moreover, I realized that `autocommit` is probably a bad idea altogether.

Application typically require transaction conflict handling, because
they are using **shared** databases. But with an embedded databases,
there is no sharing with external entities so there *always* should be,
or even *must be* a way to structure application and locking to avoid
any conflicts, preventing db isolation level issues, inability
to assert basic stuff, or just wasting time retrying things.
@dpc dpc requested a review from a team as a code owner May 12, 2024 05:27
@dpc
Copy link
Contributor Author

dpc commented May 12, 2024

Damn. This doesn't really work, because what the reading-side sees is being swapped at the moment of commit.

@maan2003
Copy link
Member

right, locking is better than autocommit. just have a lock for a set of keys.

@dpc dpc marked this pull request as draft May 12, 2024 16:15
@dpc
Copy link
Contributor Author

dpc commented May 12, 2024

Having to lock more than across the tx commit ruins it though. :(

@dpc dpc changed the title fix: panic: Must deleted existing spendable note fix: panic: Must deleted existing spendable note [broken, don't land] May 12, 2024
@m1sterc001guy
Copy link
Contributor

Probably not necessary anymore after fixing #5195

@dpc dpc closed this May 13, 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

Successfully merging this pull request may close these issues.

flake: panic: Must deleted existing spendable note
3 participants