You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just looking at beforeSleep() in server.cpp, I can see locker.disarm() and locker.arm() before calling db methods, eg:
locker.disarm();
for (redisDb *db : vecdb)
db->commitChanges();
locker.arm();
Taking a stab in the dark, do we also need to add them for the processChanges() call? ie:
locker.disarm(); <---------------- THIS
for (int idb = 0; idb < cserver.dbnum; ++idb) {
if (g_pserver->db[idb]->processChanges(false))
vecdb.push_back(g_pserver->db[idb]);
}
locker.arm(); <---------------- AND THIS
Will keep investigating, and report back here if I find anything else helpful.
The text was updated successfully, but these errors were encountered:
std::unique_lock<fastlock> ul(m_lock, std::defer_lock);
bool fLocked = ul.try_lock(); <-- LOCK A
size_t count = m_spstorage->count(); <-- LOCK B
And in db.cpp processChanges(), we have:
m_spstorage->beginWriteBatch(); <-- LOCK B
...
serializeAndStoreChange(); <-- LOCK A
If 2 different threads call the 2 methods above, they can cause a deadlock. In addition, it looks like the processChanges() is protected by the global lock, but the count() is not.
On my local, I have made this one-liner change in StorageCache.cpp:
size_t StorageCache::count() const
{
size_t count = m_spstorage->count(); <--- MOVED from bottom
std::unique_lock<fastlock> ul(m_lock, std::defer_lock);
bool fLocked = ul.try_lock();
// size_t count = m_spstorage->count(); <--- MOVED up
The above will ensure there is no overlapping locks between StorageCache and RocksDBStorageProvider, but I am unsure about the side effects. If it is still causing issues, will have to see if I can incorporate the global lock for the count().
Testing on async_flash branch (but looks like this bug has been around before then):
Just looking at beforeSleep() in server.cpp, I can see locker.disarm() and locker.arm() before calling db methods, eg:
Taking a stab in the dark, do we also need to add them for the processChanges() call? ie:
Will keep investigating, and report back here if I find anything else helpful.
The text was updated successfully, but these errors were encountered: