Skip to content

Commit ed70824

Browse files
nipunn1313Convex, Inc.
authored and
Convex, Inc.
committed
Classify postgres occ as overloaded (#27691)
GitOrigin-RevId: a33c491568646682eeee4355cf776dd12c924481
1 parent d4c71f7 commit ed70824

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

crates/errors/src/lib.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -674,12 +674,19 @@ impl ErrorMetadataAnyhowExt for anyhow::Error {
674674
let as_string = self.to_string();
675675
// Just doing this as a quick hack because sqlx::query has 100 throw sites.
676676
// Ideally, we would wrap sqlx and do handling there, but punting to save time.
677-
let occs = [
677+
let postgres_occs = [
678678
"could not serialize access due to read/write dependencies among transactions",
679679
"could not serialize access due to concurrent update",
680680
];
681-
if occs.into_iter().any(|occ| as_string.contains(occ)) {
682-
return self.context(ErrorMetadata::system_occ()).context(as_string);
681+
if let Some(occ) = postgres_occs
682+
.into_iter()
683+
.find(|occ| as_string.contains(occ))
684+
{
685+
// Classify postgres occ as overloaded. ErrorMetadata::OCC is specific to the
686+
// application level inside convex backend.
687+
return self
688+
.context(ErrorMetadata::overloaded("PostgresOcc", occ))
689+
.context(as_string);
683690
}
684691

685692
self

0 commit comments

Comments
 (0)