Skip to content

Wait for database update to become durable#4846

Open
kim wants to merge 1 commit intomasterfrom
kim/confirmed-database-updates
Open

Wait for database update to become durable#4846
kim wants to merge 1 commit intomasterfrom
kim/confirmed-database-updates

Conversation

@kim
Copy link
Copy Markdown
Contributor

@kim kim commented Apr 20, 2026

Confirmed reads applies only to subscription clients, calls to the the
HTTP API publish endpoint return a success response before the operation
is confirmed.

While we await scheduling of a new database, updates require to wait for
the update transaction to be confirmed. To allow this, the
TransactionOffset channel and the database's DurableOffset need to
be returned all the way up to the request handler.

Note that waiting for confirmation is almost always the right choice, so
can't be opted out of at the time of submission of this patch. Callers
may, however, extend the timeout after which waiting for confirmation is
cancelled.

Confirmed reads applies only to subscription clients, calls to the the
HTTP API publish endpoint return a success response before the operation
is confirmed.

While we await scheduling of a new database, updates require to wait for
the update transaction to be confirmed. To allow this, the
`TransactionOffset` channel and the database's `DurableOffset` need to
be returned all the way up to the request handler.

Note that waiting for confirmation is almost always the right choice, so
can't be opted out of at the time of submission of this patch. Callers
may, however, extend the timeout after which waiting for confirmation is
cancelled.
@kim kim requested review from Shubham8287 and gefjon April 20, 2026 13:22
UpdateDatabaseResult::ErrorExecutingMigration(anyhow::anyhow!(msg))
} else {
UpdateDatabaseResult::UpdatePerformed
let tx_offset = succeed(self.info.clone(), out.energy_used.into(), out.total_duration, tx);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Moving the code around for borrowchk reasons, I see that energy_quanta_used and host_execution_duration only have non-zero values in this branch (ie. EvaluateSubscribedViews).

Is this intentional and correct?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hm. It seems like there should be some energy cost to performing an update, but clearly that's separate work from this PR. I've created #4847 to track this.

Comment on lines +712 to +713
fn default_update_confirmation_timeout() -> Duration {
Duration::from_secs(5)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Duration::from_secs is const, so this could be replaced with const DEFAULT_UPDATE_CONFIRMATION_TIMEOUT: Duration = Duration::from_secs(5);.

Comment on lines +702 to +706
/// Duration to wait for a database update to become confirmed (i.e. durable).
///
/// If not given, defaults to [default_update_confirmation_timeout].
/// The parameter has no effect when creating a new database.
update_confirmation_timeout: Option<Duration>,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we want to impose an upper bound on this?

request_id: None,
timer: None,
};
//TODO: Return back event in `UpdateDatabaseResult`?
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why?

UpdateDatabaseResult::ErrorExecutingMigration(anyhow::anyhow!(msg))
} else {
UpdateDatabaseResult::UpdatePerformed
let tx_offset = succeed(self.info.clone(), out.energy_used.into(), out.total_duration, tx);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hm. It seems like there should be some energy cost to performing an update, but clearly that's separate work from this PR. I've created #4847 to track this.

@gefjon
Copy link
Copy Markdown
Contributor

gefjon commented Apr 20, 2026

Oh, something I forgot to include in my review: I agree that this is a reasonable behavior, and I don't see the need to make it more configurable than this.

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