10000 Fix BTS-527 (#14538) · arangodb/arangodb@dc386da · GitHub
[go: up one dir, main page]

Skip to content

Commit dc386da

Browse files
authored
Fix BTS-527 (#14538)
* fix potential coordinator miss on existing databases * we're catching a bad alloc on a string assignment * fix of fix potential coordinator miss on existing databases * fix of fix potential coordinator miss on existing databases * vs warnings
1 parent 50c0da7 commit dc386da

File tree

2 files changed

+56
-32
lines changed

2 files changed

+56
-32
lines changed

CHANGELOG

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
devel
22
-----
33

4+
* Fixed a bug, where Coordinators handled plan changes for databases
5+
in heartbeat thread in wrong order. Databases could be listed, but
6+
not used.
7+
48
* Automatically extend web UI sessions while they are still active.
59
The web UI can now call a backend route to renew its JWT, so there will not
610
be any rude logouts in the middle of an active session.
@@ -40,28 +44,28 @@ devel
4044
Previously, the value was ignored and WAL syncing on Windows was using a
4145
different code paths than on the other supported platforms. Now syncing is
4246
unified across all platforms, and they all call RocksDB's `SyncWAL()`.
43-
47+
4448
* Updated ArangoDB Starter to 0.15.1-preview-4.
4549

4650
* APM-132: Clean up collection statuses
4751
Removes collection statuses "new born", "loading", "unloading" and "unloaded".
4852
These statuses were last relevant with the MMFiles storage engine, when it
4953
was important to differentiate which collections are present in main memory
50-
memory and which aren't. With the RocksDB storage engine, all that was < 10000 /div>
54+
memory and which aren't. With the RocksDB storage engine, all that was
5155
automatically handled anyway, and the statuses were not important anymore.
5256

5357
The change removes the "Load" and "Unload" buttons for collections from the
5458
web interface. All collections in the web interface will be marked as
5559
"loaded" permanently.
56-
60+
5761
This change also obsoletes the `load()` and `unload()` calls for collections
5862
as well as their HTTP API equivalents. The APIs will remain in place for now
5963
but are changed to no-ops. They will removed eventually in a future version
6064
of ArangoDB. This will be announced separately.
6165

62-
* Include K_SHORTEST_PATHS and SHORTEST_PATH execution nodes in AQL query memory
63-
usage accounting. The memory used by these execution node types was previously
64-
not tracked against the configured query memory limit (BTS-411).
66+
* Include K_SHORTEST_PATHS and SHORTEST_PATH execution nodes in AQL query
67+
memory usage accounting. The memory used by these execution node types was
68+
previously not tracked against the configured query memory limit.
6569

6670
* Reduce default value for max-nodes-per-callstack to 200 for OSX, because on
6771
OSX worker threads have a stack size of only 512kb.
@@ -70,10 +74,10 @@ devel
7074
directory. This is required so we have a full copy of the JavaScript
7175
dependencies and not one that excludes some infrequently changed modules.
7276
In addition, file copying now intentionally excludes .map files as they
73-
are not needed.
77+
are not needed.
7478

75-
* Fixed BTS-408: treat positive or negative signed numbers as constants
76-
immediately during AQL query parsing.
79+
* Fixed BTS-408: treat positive or negative signed numbers as constants
80+
immediately during AQL query parsing.
7781
Previously, a value of `-1` was parsed initially as `unary minus(value(1))`,
7882
which was not treated in the same way as a constant value `value(-1)`.
7983
The value was later optimized to just `value(-1)`, but this only happened

arangod/Cluster/HeartbeatThread.cpp

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,14 +1220,55 @@ bool HeartbeatThread::handlePlanChangeCoordinator(uint64_t currentPlanVersion) {
12201220
std::vector<TRI_voc_tick_t> ids;
12211221
velocypack::Slice databases = result[0].get(std::vector<std::string>(
12221222
{AgencyCommHelper::path(), "Plan", "Databases"}));
1223-
12241223
if (!databases.isObject()) {
12251224
return false;
12261225
}
12271226

1227+
for (VPackObjectIterator::ObjectPair options : VPackObjectIterator(databases)) {
1228+
try {
1229+
ids.push_back(std::stoul(options.value.get("id").copyString()));
1230+
} catch (std::invalid_argument& e) {
1231+
LOG_TOPIC("a9233", ERR, Logger::CLUSTER)
1232+
<< "Number conversion for planned database id for " << options.key.stringView() << " failed: " << e.what();
1233+
} catch (std::out_of_range const& e) {
1234+
LOG_TOPIC("a9243", ERR, Logger::CLUSTER)
1235+
<< "Number conversion for planned database id for " << options.key.stringView() << " failed: " << e.what();
1236+
} catch (std::bad_alloc const&) {
1237+
LOG_TOPIC("a9234", FATAL, Logger::CLUSTER)
1238+
<< "Failed to allocate memory to enumerate planned databases from agency";
1239+
FATAL_ERROR_EXIT();
1240+
} catch (std::exception const& e) {
1241+
LOG_TOPIC("a9235", FATAL, Logger::CLUSTER)
1242+
<< "Failed to read planned databases " << options.key.stringView() << " from agency: " << e.what();
1243+
}
1244+
}
1245+
1246+
// get the list of databases that we know about locally
1247+
std::vector<TRI_voc_tick_t> localIds = databaseFeature.getDatabaseIds(false);
1248+
for (auto id : localIds) {
1249+
auto r = std::find(ids.begin(), ids.end(), id);
1250+
1251+
if (r == ids.end()) {
1252+
// local database not found in the plan...
1253+
std::string dbName = "n/a";
1254+
TRI_vocbase_t* db = databaseFeature.useDatabase(id);
1255+
TRI_ASSERT(db);
1256+
if (db) {
1257+
try {
1258+
dbName = db->name();
1259+
} catch (...) {
1260+
db->release();
1261+
throw;
1262+
}
1263+
db->release();
1264+
}
1265+
Result res = databaseFeature.dropDatabase(id, true);
1266+
events::DropDatabase(dbName, res, ExecContext::current());
1267+
}
1268+
}
1269+
12281270
// loop over all database names we got and create a local database
12291271
// instance if not yet present:
1230-
12311272
for (VPackObjectIterator::ObjectPair options : VPackObjectIterator(databases)) {
12321273
if (!options.value.isObject()) {
12331274
continue;
@@ -1243,9 +1284,6 @@ bool HeartbeatThread::handlePlanChangeCoordinator(uint64_t currentPlanVersion) {
12431284
TRI_ASSERT(false);
12441285
}
12451286

1246-
// known plan IDs
1247-
ids.push_back(info.getId());
1248-
12491287
auto dbName = info.getName();
12501288
TRI_vocbase_t* vocbase = databaseFeature.useDatabase(dbName);
12511289
if (vocbase == nullptr) {
@@ -1273,24 +1311,6 @@ bool HeartbeatThread::handlePlanChangeCoordinator(uint64_t currentPlanVersion) {
12731311
}
12741312
}
12751313

1276-
// get the list of databases that we know about locally
1277-
std::vector<TRI_voc_tick_t> localIds = databaseFeature.getDatabaseIds(false);
1278-
1279-
for (auto id : localIds) {
1280-
auto r = std::find(ids.begin(), ids.end(), id);
1281-
1282-
if (r == ids.end()) {
1283-
// local database not found in the plan...
1284-
TRI_vocbase_t* db = databaseFeature.useDatabase(id);
1285-
TRI_ASSERT(db);
1286-
std::string dbName = db ? db->name() : "n/a";
1287-
if (db) {
1288-
db->release();
1289-
}
1290-
Result res = databaseFeature.dropDatabase(id, true);
1291-
events::DropDatabase(dbName, res, ExecContext::current());
1292-
}
1293-
}
12941314

12951315
} else {
12961316
return false;

0 commit comments

Comments
 (0)
0