Skip to content

Commit ef9465d

Browse files
sshaderConvex, Inc.
authored and
Convex, Inc.
committed
Add OCC retries for storage action callbacks (#27003)
GitOrigin-RevId: 83a6238ee6a271547bd06a8bb6617a60bdcdf44d
1 parent 71d2dfe commit ef9465d

File tree

1 file changed

+32
-9
lines changed
  • crates/application/src/application_function_runner

1 file changed

+32
-9
lines changed

crates/application/src/application_function_runner/mod.rs

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2086,10 +2086,24 @@ impl<RT: Runtime> ActionCallbacks for ApplicationFunctionRunner<RT> {
20862086
identity: Identity,
20872087
entry: FileStorageEntry,
20882088
) -> anyhow::Result<DeveloperDocumentId> {
2089-
let mut tx = self.database.begin(identity).await?;
2090-
let id = self.file_storage.store_file_entry(&mut tx, entry).await?;
2091-
self.database
2092-
.commit_with_write_source(tx, "app_funrun_storage_store_file_entry")
2089+
let (_ts, id, _stats) = self
2090+
.database
2091+
.execute_with_occ_retries(
2092+
identity,
2093+
FunctionUsageTracker::new(),
2094+
PauseClient::new(),
2095+
"app_funrun_storage_store_file_entry",
2096+
|tx| {
2097+
async {
2098+
let id = self
2099+
.file_storage
2100+
.store_file_entry(tx, entry.clone())
2101+
.await?;
2102+
Ok(id)
2103+
}
2104+
.into()
2105+
},
2106+
)
20932107
.await?;
20942108
Ok(id)
20952109
}
@@ -2099,13 +2113,22 @@ impl<RT: Runtime> ActionCallbacks for ApplicationFunctionRunner<RT> {
20992113
identity: Identity,
21002114
storage_id: FileStorageId,
21012115
) -> anyhow::Result<()> {
2102-
let mut tx = self.database.begin(identity).await?;
2103-
self.file_storage
2104-
.delete(&mut tx, storage_id.clone())
2105-
.await?;
21062116
self.database
2107-
.commit_with_write_source(tx, "app_funrun_storage_delete")
2117+
.execute_with_occ_retries(
2118+
identity,
2119+
FunctionUsageTracker::new(),
2120+
PauseClient::new(),
2121+
"app_funrun_storage_delete",
2122+
|tx| {
2123+
async {
2124+
self.file_storage.delete(tx, storage_id.clone()).await?;
2125+
Ok(())
2126+
}
2127+
.into()
2128+
},
2129+
)
21082130
.await?;
2131+
21092132
Ok(())
21102133
}
21112134

0 commit comments

Comments
 (0)