Skip to content

Commit 3c5dceb

Browse files
BenHuddlestondaverigby
authored andcommitted
MB-45214: Log graceful due to sigint/sigterm
It's good to know why we shutdown so log if we are shutting down due to a sigint or sigterm. This logging is purposely deferred from the signal handler as we've had issues in the past logging in functions that require signal safety. Change-Id: Ia6cb6ae349b4e6b7280c6b640feb632b1adf382e Reviewed-on: https://review.couchbase.org/c/kv_engine/+/172767 Tested-by: Build Bot <[email protected]> Reviewed-by: Dave Rigby <[email protected]>
1 parent 2becb83 commit 3c5dceb

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

daemon/memcached.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@
7171
#endif
7272

7373
std::atomic<bool> memcached_shutdown;
74+
std::atomic<bool> sigint;
75+
std::atomic<bool> sigterm;
7476

7577
bool is_memcached_shutting_down() {
7678
return memcached_shutdown;
@@ -588,6 +590,7 @@ bool is_bucket_dying(Connection& c) {
588590
}
589591

590592
static void sigint_handler() {
593+
sigint = true;
591594
memcached_shutdown = true;
592595
}
593596

@@ -602,6 +605,7 @@ static void release_signal_handlers() {
602605
#else
603606

604607
static void sigterm_handler(evutil_socket_t, short, void *) {
608+
sigterm = true;
605609
memcached_shutdown = true;
606610
}
607611

@@ -1038,7 +1042,9 @@ int memcached_main(int argc, char** argv) {
10381042
main_base->loopForever();
10391043
}
10401044

1041-
LOG_INFO_RAW("Initiating graceful shutdown.");
1045+
LOG_INFO("Initiating graceful shutdown. sigint:{} sigterm:{}",
1046+
sigint,
1047+
sigterm);
10421048
BucketManager::instance().destroyAll();
10431049

10441050
if (parent_monitor) {

0 commit comments

Comments
 (0)