mirror of https://gitee.com/bigwinds/arangodb
Fix bugs with database lists on coordinator.
This commit is contained in:
parent
9778bc16fd
commit
aa341f790f
|
@ -472,7 +472,7 @@ static int OpenDatabases (TRI_server_t* server,
|
||||||
MUTEX_LOCKER(server->_databasesMutex);
|
MUTEX_LOCKER(server->_databasesMutex);
|
||||||
auto oldLists = server->_databasesLists.load();
|
auto oldLists = server->_databasesLists.load();
|
||||||
auto newLists = new DatabasesLists(*oldLists);
|
auto newLists = new DatabasesLists(*oldLists);
|
||||||
// Now try catch here, if we crash here because out of memory...
|
// No try catch here, if we crash here because out of memory...
|
||||||
|
|
||||||
for (size_t i = 0; i < n; ++i) {
|
for (size_t i = 0; i < n; ++i) {
|
||||||
TRI_vocbase_t* vocbase;
|
TRI_vocbase_t* vocbase;
|
||||||
|
@ -759,8 +759,10 @@ static int CloseDatabases (TRI_server_t* server) {
|
||||||
// and only then really destroy the vocbases:
|
// and only then really destroy the vocbases:
|
||||||
|
|
||||||
// Build the new value:
|
// Build the new value:
|
||||||
auto newList = new DatabasesLists();
|
auto oldList = server->_databasesLists.load();
|
||||||
|
decltype(oldList) newList = nullptr;
|
||||||
try {
|
try {
|
||||||
|
newList = new DatabasesLists();
|
||||||
newList->_droppedDatabases = server->_databasesLists.load()->_droppedDatabases;
|
newList->_droppedDatabases = server->_databasesLists.load()->_droppedDatabases;
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
|
@ -769,7 +771,6 @@ static int CloseDatabases (TRI_server_t* server) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace the old by the new:
|
// Replace the old by the new:
|
||||||
auto oldList = server->_databasesLists.load();
|
|
||||||
server->_databasesLists = newList;
|
server->_databasesLists = newList;
|
||||||
server->_databasesProtector.scan();
|
server->_databasesProtector.scan();
|
||||||
|
|
||||||
|
@ -810,8 +811,10 @@ static int CloseDroppedDatabases (TRI_server_t* server) {
|
||||||
// and only then really destroy the vocbases:
|
// and only then really destroy the vocbases:
|
||||||
|
|
||||||
// Build the new value:
|
// Build the new value:
|
||||||
auto newList = new DatabasesLists();
|
auto oldList = server->_databasesLists.load();
|
||||||
|
decltype(oldList) newList = nullptr;
|
||||||
try {
|
try {
|
||||||
|
newList = new DatabasesLists();
|
||||||
newList->_databases = server->_databasesLists.load()->_databases;
|
newList->_databases = server->_databasesLists.load()->_databases;
|
||||||
newList->_coordinatorDatabases = server->_databasesLists.load()->_coordinatorDatabases;
|
newList->_coordinatorDatabases = server->_databasesLists.load()->_coordinatorDatabases;
|
||||||
}
|
}
|
||||||
|
@ -821,7 +824,6 @@ static int CloseDroppedDatabases (TRI_server_t* server) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace the old by the new:
|
// Replace the old by the new:
|
||||||
auto oldList = server->_databasesLists.load();
|
|
||||||
server->_databasesLists = newList;
|
server->_databasesLists = newList;
|
||||||
server->_databasesProtector.scan();
|
server->_databasesProtector.scan();
|
||||||
|
|
||||||
|
@ -1545,9 +1547,9 @@ static void DatabaseManager (void* data) {
|
||||||
|
|
||||||
// Build the new value:
|
// Build the new value:
|
||||||
auto oldLists = server->_databasesLists.load();
|
auto oldLists = server->_databasesLists.load();
|
||||||
decltype(oldLists) newLists;
|
decltype(oldLists) newLists = nullptr;
|
||||||
newLists = new DatabasesLists();
|
|
||||||
try {
|
try {
|
||||||
|
newLists = new DatabasesLists();
|
||||||
newLists->_databases = oldLists->_databases;
|
newLists->_databases = oldLists->_databases;
|
||||||
newLists->_coordinatorDatabases = oldLists->_coordinatorDatabases;
|
newLists->_coordinatorDatabases = oldLists->_coordinatorDatabases;
|
||||||
for (TRI_vocbase_t* vocbase : oldLists->_droppedDatabases) {
|
for (TRI_vocbase_t* vocbase : oldLists->_droppedDatabases) {
|
||||||
|
@ -1744,8 +1746,6 @@ int TRI_InitServer (TRI_server_t* server,
|
||||||
// database hashes and vectors
|
// database hashes and vectors
|
||||||
// ...........................................................................
|
// ...........................................................................
|
||||||
|
|
||||||
server->_databasesLists = new DatabasesLists();
|
|
||||||
|
|
||||||
server->_disableReplicationAppliers = disableAppliers;
|
server->_disableReplicationAppliers = disableAppliers;
|
||||||
|
|
||||||
server->_initialized = true;
|
server->_initialized = true;
|
||||||
|
@ -2097,13 +2097,14 @@ int TRI_CreateCoordinatorDatabaseServer (TRI_server_t* server,
|
||||||
auto oldLists = server->_databasesLists.load();
|
auto oldLists = server->_databasesLists.load();
|
||||||
decltype(oldLists) newLists = nullptr;
|
decltype(oldLists) newLists = nullptr;
|
||||||
try {
|
try {
|
||||||
auto newLists = new DatabasesLists(*oldLists);
|
newLists = new DatabasesLists(*oldLists);
|
||||||
newLists->_coordinatorDatabases.insert(
|
newLists->_coordinatorDatabases.insert(
|
||||||
std::make_pair(std::string(vocbase->_name), vocbase));
|
std::make_pair(std::string(vocbase->_name), vocbase));
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
delete newLists;
|
delete newLists;
|
||||||
throw;
|
delete vocbase;
|
||||||
|
return TRI_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
server->_databasesLists = newLists;
|
server->_databasesLists = newLists;
|
||||||
server->_databasesProtector.scan();
|
server->_databasesProtector.scan();
|
||||||
|
@ -2245,8 +2246,9 @@ int TRI_CreateDatabaseServer (TRI_server_t* server,
|
||||||
{
|
{
|
||||||
MUTEX_LOCKER(server->_databasesMutex);
|
MUTEX_LOCKER(server->_databasesMutex);
|
||||||
auto oldLists = server->_databasesLists.load();
|
auto oldLists = server->_databasesLists.load();
|
||||||
auto newLists = new DatabasesLists(*oldLists);
|
decltype(oldLists) newLists = nullptr;
|
||||||
try {
|
try {
|
||||||
|
newLists = new DatabasesLists(*oldLists);
|
||||||
newLists->_databases.insert(
|
newLists->_databases.insert(
|
||||||
std::make_pair(std::string(vocbase->_name), vocbase));
|
std::make_pair(std::string(vocbase->_name), vocbase));
|
||||||
}
|
}
|
||||||
|
@ -2254,9 +2256,11 @@ int TRI_CreateDatabaseServer (TRI_server_t* server,
|
||||||
LOG_ERROR("Out of memory for putting new database into list!");
|
LOG_ERROR("Out of memory for putting new database into list!");
|
||||||
// This is bad, but at least we do not crash!
|
// This is bad, but at least we do not crash!
|
||||||
}
|
}
|
||||||
server->_databasesLists = newLists;
|
if (newLists != nullptr) {
|
||||||
server->_databasesProtector.scan();
|
server->_databasesLists = newLists;
|
||||||
delete oldLists;
|
server->_databasesProtector.scan();
|
||||||
|
delete oldLists;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // release DatabaseCreateLock
|
} // release DatabaseCreateLock
|
||||||
|
@ -2772,7 +2776,7 @@ TRI_vocbase_operationmode_e TRI_GetOperationModeServer () {
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
TRI_server_t::TRI_server_t ()
|
TRI_server_t::TRI_server_t ()
|
||||||
: _databasesLists(nullptr),
|
: _databasesLists(new DatabasesLists()),
|
||||||
_applicationEndpointServer(nullptr),
|
_applicationEndpointServer(nullptr),
|
||||||
_indexPool(nullptr),
|
_indexPool(nullptr),
|
||||||
_queryRegistry(nullptr),
|
_queryRegistry(nullptr),
|
||||||
|
|
Loading…
Reference in New Issue