8000 equalising devel and 3.4 in agency/cluster (#7755) · arangodb/arangodb@b9409f6 · GitHub
[go: up one dir, main page]

Skip to content

Commit b9409f6

Browse files
kvahedneunhoef
authored andcommitted
equalising devel and 3.4 in agency/cluster (#7755)
* equalising devel and 3.4 in agency/cluster * need to move code higher up * Correct two error codes (shutting down).
1 parent 87fbc67 commit b9409f6

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

arangod/Cluster/SynchronizeShard.cpp

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,12 @@ static arangodb::Result cancelBarrier(
388388
return arangodb::Result();
389389
}
390390

391+
392+
static inline bool isStopping() {
393+
return application_features::ApplicationServer::isStopping();
394+
}
395+
396+
391397
arangodb::Result SynchronizeShard::getReadLock(
392398
std::string const& endpoint, std::string const& database,
393399
std::string const& collection, std::string const& clientId,
@@ -423,6 +429,11 @@ arangodb::Result SynchronizeShard::getReadLock(
423429
size_t count = 0;
424430
size_t maxTries = static_cast<size_t>(std::floor(600.0 / sleepTime));
425431
while (++count < maxTries) { // wait for some time until read lock established:
432+
433+
if (isStopping()) {
434+
return arangodb::Result(TRI_ERROR_SHUTTING_DOWN);
435+
}
436+
426437
// Now check that we hold the read lock:
427438
auto putres = cc->syncRequest(
428439
TRI_NewTickServer(), endpoint, rest::RequestType::PUT, url, body.toJson(),
@@ -467,10 +478,6 @@ arangodb::Result SynchronizeShard::getReadLock(
467478
return arangodb::Result(TRI_ERROR_CLUSTER_TIMEOUT, "startReadLockOnLeader: giving up");
468479
}
469480

470-
static inline bool isStopping() {
471-
return application_features::ApplicationServer::isStopping();
472-
}
473-
474481
arangodb::Result SynchronizeShard::startReadLockOnLeader(
475482
std::string const& endpoint, std::string const& database,
476483
std::string const& collection, std::string const& clientId,
@@ -804,7 +811,7 @@ bool SynchronizeShard::first() {
804811
"synchronizeOneShard: synchronization failed for shard ");
805812
errorMessage += shard + ": shutdown in progress, giving up";
806813
LOG_TOPIC(INFO, Logger::MAINTENANCE) << errorMessage;
807-
_result.reset(TRI_ERROR_INTERNAL, errorMessage);
814+
_result.reset(TRI_ERROR_SHUTTING_DOWN, errorMessage);
808815
return false;
809816
}
810817

@@ -941,6 +948,13 @@ ResultT<TRI_voc_tick_t> SynchronizeShard::catchupWithReadLock(
941948
double timeout = 300.0;
942949
TRI_voc_tick_t tickReached = 0;
943950
while (didTimeout && tries++ < 18) { // This will try to sync for at most 1 hour. (200 * 18 == 3600)
951+
952+
if (isStopping()) {
953+
std::string errorMessage =
954+
"synchronizeOneShard: startReadLockOnLeader (soft): shutting down";
955+
return ResultT<TRI_voc_tick_t>::error(TRI_ERROR_SHUTTING_DOWN, errorMessage);
956+
}
957+
944958
didTimeout = false;
945959
// Now ask for a "soft stop" on the leader, in case of mmfiles, this
946960
// will be a hard stop, but for rocksdb, this is a no-op:

0 commit comments

Comments
 (0)
0