Skip to content

Commit 72ea73d

Browse files
hamz2awoshilapin
authored andcommitted
editoast: add Deadlocks comment
1 parent 54df292 commit 72ea73d

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

editoast/editoast_models/src/db_connection_pool.rs

+8
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,14 @@ impl DbConnectionPoolV2 {
134134
/// # }
135135
/// ```
136136
///
137+
/// ### Deadlocks
138+
///
139+
/// We encountered a deadlock error in our tests,
140+
/// especially those using `empty_infra` and `small_infra`.
141+
/// Adding `#[serial_test::serial]` solved the issue.
142+
/// We tried increasing the deadlock timeout, but that didn't work.
143+
/// Using random `infra_id` with rand didn't help either.
144+
///
137145
/// ## Guidelines
138146
///
139147
/// To prevent these issues, prefer the following patterns:

editoast/src/modelsv2/infra.rs

+1
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ pub mod tests {
350350
}
351351

352352
#[rstest]
353+
// PostgreSQL deadlock can happen in this test, see section `Deadlock` of [DbConnectionPoolV2::get] for more information
353354
#[serial_test::serial]
354355
async fn persists_railjson_ko_version() {
355356
let db_pool = DbConnectionPoolV2::for_tests();

editoast/src/views/infra/mod.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,7 @@ pub mod tests {
658658
}
659659

660660
#[rstest]
661+
// PostgreSQL deadlock can happen in this test, see section `Deadlock` of [DbConnectionPoolV2::get] for more information
661662
#[serial_test::serial]
662663
async fn infra_clone_empty() {
663664
let app = TestAppBuilder::default_app();
@@ -682,7 +683,9 @@ pub mod tests {
682683
nb: i64,
683684
}
684685

685-
#[rstest] // Slow test
686+
#[rstest]
687+
// Slow test
688+
// PostgreSQL deadlock can happen in this test, see section `Deadlock` of [DbConnectionPoolV2::get] for more information
686689
#[serial_test::serial]
687690
async fn infra_clone() {
688691
let app = TestAppBuilder::default_app();

editoast/src/views/infra/railjson.rs

+2
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ mod tests {
196196
use editoast_schemas::infra::SwitchType;
197197

198198
#[rstest]
199+
// PostgreSQL deadlock can happen in this test, see section `Deadlock` of [DbConnectionPoolV2::get] for more information
199200
#[serial_test::serial]
200201
async fn test_get_railjson() {
201202
let app = TestAppBuilder::default_app();
@@ -221,6 +222,7 @@ mod tests {
221222
}
222223

223224
#[rstest]
225+
// PostgreSQL deadlock can happen in this test, see section `Deadlock` of [DbConnectionPoolV2::get] for more information
224226
#[serial_test::serial]
225227
async fn test_post_railjson() {
226228
let app = TestAppBuilder::default_app();

0 commit comments

Comments
 (0)