Skip to content

Commit

Permalink
fix: prevent thread panic on large tag values using postgres
Browse files Browse the repository at this point in the history
Exceptionally large tag values (thousands of characters) can result in
an error from postgres: index row size exceeds btree version 4 maximum
2704 for index "tag_value_idx".  This panics the writer thread, and
prevents further writes from succeeding.

This change simply removes the unwrap, allowing the error to propagate
where it is sent as a write error back to the client.  The error
message could be improved.

scsibug#196
  • Loading branch information
scsibug committed Jun 6, 2024
1 parent b04ab76 commit 4f518fd
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/repo/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,17 +187,15 @@ ON CONFLICT (id) DO NOTHING"#,
.bind(tag_name)
.bind(hex::decode(tag_val).ok())
.execute(&mut tx)
.await
.unwrap();
.await?;
} else {
sqlx::query("INSERT INTO tag (event_id, \"name\", value, value_hex) VALUES($1, $2, $3, NULL) \
ON CONFLICT (event_id, \"name\", value, value_hex) DO NOTHING")
.bind(&id_blob)
.bind(tag_name)
.bind(tag_val.as_bytes())
.execute(&mut tx)
.await
.unwrap();
.await?;
}
}
None => {}
Expand Down

0 comments on commit 4f518fd

Please sign in to comment.