Retry on foreign key violation

This commit is contained in:
Diggory Blake 2021-09-21 12:14:32 +01:00
parent 08b71b59ae
commit 9424605cfb
No known key found for this signature in database
GPG key ID: E6BDFA83146ABD40
3 changed files with 5 additions and 3 deletions

View file

@ -1,6 +1,6 @@
[package]
name = "sqlxmq"
version = "0.3.0"
version = "0.3.1"
authors = ["Diggory Blake <diggsey@googlemail.com>"]
edition = "2018"
license = "MIT OR Apache-2.0"
@ -23,7 +23,7 @@ uuid = { version = "0.8.2", features = ["v4"] }
log = "0.4.14"
serde_json = "1.0.64"
serde = "1.0.124"
sqlxmq_macros = { version = "0.3.0", path = "sqlxmq_macros" }
sqlxmq_macros = { version = "0.3.1", path = "sqlxmq_macros" }
anymap2 = "0.13.0"
[features]

View file

@ -1,6 +1,6 @@
[package]
name = "sqlxmq_macros"
version = "0.3.0"
version = "0.3.1"
authors = ["Diggory Blake <diggsey@googlemail.com>"]
edition = "2018"
license = "MIT OR Apache-2.0"

View file

@ -243,6 +243,8 @@ pub fn should_retry(error: &sqlx::Error) -> bool {
// It's more readable as a match
#[allow(clippy::match_like_matches_macro)]
match (db_error.code().as_deref(), db_error.constraint().as_deref()) {
// Foreign key constraint violation on ordered channel
(Some("23503"), Some("mq_msgs_after_message_id_fkey")) => true,
// Unique constraint violation on ordered channel
(Some("23505"), Some("mq_msgs_channel_name_channel_args_after_message_id_idx")) => true,
// Serialization failure