@@ -388,6 +388,12 @@ static arangodb::Result cancelBarrier(
388
388
return arangodb::Result ();
389
389
}
390
390
391
+
392
+ static inline bool isStopping () {
393
+ return application_features::ApplicationServer::isStopping ();
394
+ }
395
+
396
+
391
397
arangodb::Result SynchronizeShard::getReadLock (
392
398
std::string const & endpoint, std::string const & database,
393
399
std::string const & collection, std::string const & clientId,
@@ -423,6 +429,11 @@ arangodb::Result SynchronizeShard::getReadLock(
423
429
size_t count = 0 ;
424
430
size_t maxTries = static_cast <size_t >(std::floor (600.0 / sleepTime));
425
431
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
+
426
437
// Now check that we hold the read lock:
427
438
auto putres = cc->syncRequest (
428
439
TRI_NewTickServer (), endpoint, rest::RequestType::PUT, url, body.toJson (),
@@ -467,10 +478,6 @@ arangodb::Result SynchronizeShard::getReadLock(
467
478
return arangodb::Result (TRI_ERROR_CLUSTER_TIMEOUT, " startReadLockOnLeader: giving up" );
468
479
}
469
480
470
- static inline bool isStopping () {
471
- return application_features::ApplicationServer::isStopping ();
472
- }
473
-
474
481
arangodb::Result SynchronizeShard::startReadLockOnLeader (
475
482
std::string const & endpoint, std::string const & database,
476
483
std::string const & collection, std::string const & clientId,
@@ -804,7 +811,7 @@ bool SynchronizeShard::first() {
804
811
" synchronizeOneShard: synchronization failed for shard " );
805
812
errorMessage += shard + " : shutdown in progress, giving up" ;
806
813
LOG_TOPIC (INFO, Logger::MAINTENANCE) << errorMessage;
807
- _result.reset (TRI_ERROR_INTERNAL , errorMessage);
814
+ _result.reset (TRI_ERROR_SHUTTING_DOWN , errorMessage);
808
815
return false ;
809
816
}
810
817
@@ -941,6 +948,13 @@ ResultT<TRI_voc_tick_t> SynchronizeShard::catchupWithReadLock(
941
948
double timeout = 300.0 ;
942
949
TRI_voc_tick_t tickReached = 0 ;
943
950
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
+
944
958
didTimeout = false ;
945
959
// Now ask for a "soft stop" on the leader, in case of mmfiles, this
946
960
// will be a hard stop, but for rocksdb, this is a no-op:
0 commit comments