Skip to content

Commit

Permalink
editoast: add Deadlocks comment
Browse files Browse the repository at this point in the history
  • Loading branch information
hamz2a authored and woshilapin committed Jul 10, 2024
1 parent 54df292 commit aea5510
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 2 deletions.
8 changes: 8 additions & 0 deletions editoast/editoast_models/src/db_connection_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,14 @@ impl DbConnectionPoolV2 {
/// # }
/// ```
///
/// ### Deadlocks
///
/// We encountered a deadlock error in our tests,
/// especially those using `empty_infra` and `small_infra`.
/// Adding `#[serial_test::serial]` solved the issue.
/// We tried increasing the deadlock timeout, but that didn't work.
/// Using random `infra_id` with rand didn't help either.
///
/// ## Guidelines
///
/// To prevent these issues, prefer the following patterns:
Expand Down
5 changes: 4 additions & 1 deletion editoast/src/generated_data/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,10 @@ pub mod tests {
use crate::modelsv2::fixtures::create_empty_infra;
use editoast_models::DbConnectionPoolV2;

#[rstest] // Slow test
#[rstest]
// Slow test
// PostgreSQL deadlock can happen in this test, see section `Deadlock` of [DbConnectionPoolV2::get] for more information
#[serial_test::serial]
async fn refresh_all_test() {
let db_pool = DbConnectionPoolV2::for_tests();
let infra = create_empty_infra(db_pool.get_ok().deref_mut()).await;
Expand Down
2 changes: 2 additions & 0 deletions editoast/src/modelsv2/infra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,8 @@ pub mod tests {
}

#[rstest]
// PostgreSQL deadlock can happen in this test, see section `Deadlock` of [DbConnectionPoolV2::get] for more information
#[serial_test::serial]
async fn clone_infra_with_new_name_returns_new_cloned_infra() {
// GIVEN
let db_pool = DbConnectionPoolV2::for_tests();
Expand Down
5 changes: 4 additions & 1 deletion editoast/src/views/infra/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,10 @@ pub mod tests {
assert_eq!(refreshed_infras.infra_refreshed, vec![empty_infra.id]);
}

#[rstest] // Slow test
#[rstest]
// Slow test
// PostgreSQL deadlock can happen in this test, see section `Deadlock` of [DbConnectionPoolV2::get] for more information
#[serial_test::serial]
async fn infra_refresh_force() {
let app = TestAppBuilder::default_app();
let db_pool = app.db_pool();
Expand Down
2 changes: 2 additions & 0 deletions editoast/src/views/infra/railjson.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ mod tests {
use editoast_schemas::infra::SwitchType;

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

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

0 comments on commit aea5510

Please sign in to comment.