diff options
author | Ben Radford <benradf@users.noreply.github.com> | 2023-04-11 10:22:07 +0100 |
---|---|---|
committer | Ben Radford <benradf@users.noreply.github.com> | 2023-04-11 11:15:34 +0100 |
commit | 7c56e842133afe14812270c34cda3dc0a3da8aa6 (patch) | |
tree | 6d8892879f18699c773eb45b025c0f1e09c7a0bb /src/libstore/sqlite.cc | |
parent | 7f5ca6192d091090bc71ab7bf96dd4acf0f1d376 (diff) |
Warn after a second of being busy instead of immediately.
Getting the occasional SQLITE_BUSY is expected when the database is being
accessed concurrently. The retry will likely succeed so it is pointless to warn
immediately. Instead we track how long each retrySQLite block has been running,
and only begin warning after a second has elapsed (and then every 10 seconds
subsequently).
Diffstat (limited to 'src/libstore/sqlite.cc')
-rw-r--r-- | src/libstore/sqlite.cc | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/src/libstore/sqlite.cc b/src/libstore/sqlite.cc index 871f2f3be..c57e58fe0 100644 --- a/src/libstore/sqlite.cc +++ b/src/libstore/sqlite.cc @@ -239,14 +239,9 @@ SQLiteTxn::~SQLiteTxn() } } -void handleSQLiteBusy(const SQLiteBusy & e) +void handleSQLiteBusy(const SQLiteBusy & e, bool shouldWarn) { - static std::atomic<time_t> lastWarned{0}; - - time_t now = time(0); - - if (now > lastWarned + 10) { - lastWarned = now; + if (shouldWarn) { logWarning({ .msg = hintfmt(e.what()) }); |