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

Handle failed changes properly #269

Merged
merged 3 commits into from
Nov 29, 2024
Merged

Handle failed changes properly #269

merged 3 commits into from
Nov 29, 2024

Conversation

somtochiama
Copy link
Contributor

@somtochiama somtochiama commented Nov 28, 2024

This pull request adds the following changes:

  • The use of savepoints for commit single versions are handled within process_multiple_changes so if one version fails we can continue with the others.
  • It reverts the behaviour of removing failed versions from the seen map as this can cause duplicate changes from broadcasts to be re-sent. Now the changes will eventually be retried when the cache is cleared.
  • We now maintain the same size for the both the cache and the queue, so that we never have duplicate items in the queue

Copy link
Member

@jeromegn jeromegn left a comment

Choose a reason for hiding this comment

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

Left a few comments.

pub fn process_complete_version(
agent: Agent,
tx: &Transaction,
sp: &Savepoint,
Copy link
Member

Choose a reason for hiding this comment

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

Little bit of fun knowledge: Both Transaction and Savepoint implement Deref<Target=Connection>, so we could use &Connection here as a type and it'd "just work" properly, but it is nicer to have it explicit like you did there. This makes it harder to send the wrong type.

crates/corro-agent/src/agent/handlers.rs Outdated Show resolved Hide resolved
crates/corro-agent/src/agent/tests.rs Outdated Show resolved Hide resolved
.query_row([], |row| row.get::<_, String>(0));
assert!(res.is_err());
assert_eq!(res, Err(rusqlite::Error::QueryReturnedNoRows));

Copy link
Member

Choose a reason for hiding this comment

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

Can you also check that the db_version inserted and the ones Corrosion associated with its internal version are correct? Possibly by trying to apply the bad change first.

I vaguely recall we do some db version arithmetics and we might need to subtract when we're rolling back a savepoint.

@somtochiama somtochiama requested a review from jeromegn November 28, 2024 20:57
This enables us to process other vesions in process_multiple_changes
even if one of them fails
@somtochiama somtochiama force-pushed the somto/fix-failed-changes branch from bea5135 to 68daa16 Compare November 28, 2024 21:12
@somtochiama somtochiama merged commit 7d4512f into main Nov 29, 2024
3 of 4 checks passed
@somtochiama somtochiama deleted the somto/fix-failed-changes branch November 29, 2024 17:43
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.

2 participants