From 0526c16adbc848dc9b245e41926fe3113a368e27 Mon Sep 17 00:00:00 2001 From: Igor Aleksanov Date: Fri, 4 Mar 2022 15:09:56 +0300 Subject: [PATCH] Run database threads in a single thread --- infrastructure/zk/src/test/test.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/infrastructure/zk/src/test/test.ts b/infrastructure/zk/src/test/test.ts index 93642b9829..d05f6b5e99 100644 --- a/infrastructure/zk/src/test/test.ts +++ b/infrastructure/zk/src/test/test.ts @@ -21,19 +21,23 @@ async function runOnTestDb(reset: boolean, dir: string, command: string) { } export async function db(reset: boolean, ...args: string[]) { + // Running many similar transactions in parallel can cause db deadlocks, so we run + // them in a single thread. Given that tests are pretty fast, it's not a big problem. await runOnTestDb( reset, 'core/lib/storage', - `cargo test --release -p zksync_storage -- --ignored --nocapture + `cargo test --release -p zksync_storage --lib -- --ignored --nocapture --test-threads=1 ${args.join(' ')}` ); } export async function rustApi(reset: boolean, ...args: string[]) { + // Running many similar transactions in parallel can cause db deadlocks, so we run + // them in a single thread. Given that tests are pretty fast, it's not a big problem. await runOnTestDb( reset, 'core/bin/zksync_api', - `cargo test --release -p zksync_api -- --ignored --nocapture api_server + `cargo test --release -p zksync_api --lib -- --ignored --nocapture --test-threads=1 api_server ${args.join(' ')}` ); }