mirror of
https://github.com/scsibug/nostr-rs-relay.git
synced 2024-11-12 14:29:06 -05:00
fix: prevent thread panic on large tag values using postgres
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. https://github.com/scsibug/nostr-rs-relay/issues/196
This commit is contained in:
parent
b04ab76e73
commit
4f518fd0e7
|
@ -187,8 +187,7 @@ 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")
|
||||
|
@ -196,8 +195,7 @@ ON CONFLICT (id) DO NOTHING"#,
|
|||
.bind(tag_name)
|
||||
.bind(tag_val.as_bytes())
|
||||
.execute(&mut tx)
|
||||
.await
|
||||
.unwrap();
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
None => {}
|
||||
|
|
Loading…
Reference in New Issue
Block a user