Skip to content

Commit 4ed550b

Browse files
danielgafniion-elgreco
authored andcommitted
🐛 retry creation of table with version 0
Signed-off-by: danielgafni <[email protected]>
1 parent d16f10c commit 4ed550b

File tree

1 file changed

+27
-12
lines changed
  • crates/core/src/kernel/transaction

1 file changed

+27
-12
lines changed

crates/core/src/kernel/transaction/mod.rs

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -618,19 +618,34 @@ impl<'a> std::future::IntoFuture for PreparedCommit<'a> {
618618
let commit_or_bytes = this.commit_or_bytes;
619619

620620
if this.table_data.is_none() {
621-
this.log_store
621+
match this
622+
.log_store
622623
.write_commit_entry(0, commit_or_bytes.clone(), this.operation_id)
623-
.await?;
624-
return Ok(PostCommit {
625-
version: 0,
626-
data: this.data,
627-
create_checkpoint: false,
628-
cleanup_expired_logs: None,
629-
log_store: this.log_store,
630-
table_data: None,
631-
custom_execute_handler: this.post_commit_hook_handler,
632-
metrics: CommitMetrics { num_retries: 0 },
633-
});
624+
.await
625+
{
626+
Ok(_) => {
627+
return Ok(PostCommit {
628+
version: 0,
629+
data: this.data,
630+
create_checkpoint: false,
631+
cleanup_expired_logs: None,
632+
log_store: this.log_store,
633+
table_data: None,
634+
custom_execute_handler: this.post_commit_hook_handler,
635+
metrics: CommitMetrics { num_retries: 0 },
636+
})
637+
}
638+
Err(TransactionError::VersionAlreadyExists(0)) => {
639+
// this can happen if the table has been created by another writer since the `this.table_data.is_none()` check above
640+
// therefore, we need to re-download the table state
641+
this.table_data = this
642+
.log_store
643+
.read_commit_entry(this.log_store.get_latest_version(0).await?)
644+
.await?;
645+
Ok(())
646+
}
647+
Err(e) => Err(e),
648+
}?;
634649
}
635650

636651
// unwrap() is safe here due to the above check

0 commit comments

Comments
 (0)