stress: prevent thread from holding write lock and then stopping

When a stress thread runs out of work, execute COMMIT and ignore
the result.

This prevents the currently extremely common scenario where:

- Thread x does BEGIN
- Thread x does e.g. INSERT ...

Then runs out of iterations and stops. No other threads can write
anything and they just wait for 5 seconds (busy timeout) and then
try again, forever.
This commit is contained in:
Jussi Saurio
2025-10-17 08:47:40 +03:00
parent a82e8c9c23
commit bae3a42564

View File

@@ -629,6 +629,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
}
}
}
// In case this thread is running an exclusive transaction, commit it so that it doesn't block other threads.
let _ = conn.execute("COMMIT", ()).await;
Ok::<_, Box<dyn std::error::Error + Send + Sync>>(())
});
handles.push(handle);