fix(Core/Database): allow reopening a DatabaseWorkerPool after a failed Open() (#27585)

This commit is contained in:
Keleborn
2026-09-11 13:08:27 +02:00
committed by GitHub
parent 527e91b9b2
commit c1893c0e51
2 changed files with 14 additions and 0 deletions
+9
View File
@@ -102,6 +102,15 @@ public:
_condition.notify_all();
}
// Reopens the queue after Cancel()/Shutdown() so new consumers can be attached.
// Callers must make sure the previous consumers have already stopped.
void Reset()
{
std::lock_guard<std::mutex> lock(_queueLock);
_cancel = false;
_shutdown = false;
}
private:
template<typename E = T>
typename std::enable_if<std::is_pointer<E>::value>::type DeleteQueuedObject(E& obj)
@@ -91,6 +91,11 @@ uint32 DatabaseWorkerPool<T>::Open()
LOG_INFO("sql.driver", "Opening DatabasePool '{}'. Asynchronous connections: {}, synchronous connections: {}.",
GetDatabaseName(), _async_threads, _synch_threads);
_queue->Cancel();
_connections[IDX_ASYNC].clear();
_connections[IDX_SYNCH].clear();
_queue->Reset();
uint32 error = OpenConnections(IDX_ASYNC, _async_threads);
if (error)