Increase to 20 before warning about db queue size. Put lock in it's own scope so that we unlock before notifying

This commit is contained in:
Isaac Connor 2021-11-24 13:44:45 -05:00
parent 67556430c6
commit 77d3109152
1 changed files with 6 additions and 4 deletions

View File

@ -251,11 +251,11 @@ void zmDbQueue::process() {
mCondition.wait(lock); mCondition.wait(lock);
} }
while (!mQueue.empty()) { while (!mQueue.empty()) {
if (mQueue.size() > 10) { if (mQueue.size() > 20) {
Logger *log = Logger::fetch(); Logger *log = Logger::fetch();
Logger::Level db_level = log->databaseLevel(); Logger::Level db_level = log->databaseLevel();
log->databaseLevel(Logger::NOLOG); log->databaseLevel(Logger::NOLOG);
Warning("db queue size has grown larger %zu than 10 entries", mQueue.size()); Warning("db queue size has grown larger %zu than 20 entries", mQueue.size());
log->databaseLevel(db_level); log->databaseLevel(db_level);
} }
std::string sql = mQueue.front(); std::string sql = mQueue.front();
@ -271,8 +271,10 @@ void zmDbQueue::process() {
void zmDbQueue::push(std::string &&sql) { void zmDbQueue::push(std::string &&sql) {
if (mTerminate) return; if (mTerminate) return;
std::unique_lock<std::mutex> lock(mMutex); {
mQueue.push(std::move(sql)); std::unique_lock<std::mutex> lock(mMutex);
mQueue.push(std::move(sql));
}
mCondition.notify_all(); mCondition.notify_all();
} }