From: xie xingguo Date: Thu, 13 Jul 2017 00:21:48 +0000 (+0800) Subject: osd/OSD: gracefully shutdown on error exit during init X-Git-Tag: ses5-milestone9~1^2~13^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a98c7e84ac12d3e6fb4076cf52cab59c4aa9d59e;p=ceph.git osd/OSD: gracefully shutdown on error exit during init This can avoid crashes as below: 0> 2017-07-12 09:34:47.427438 7f320ce61b80 -1 /home/xxg/build/ceph-dev/src/common/HeartbeatMap.cc: In function 'ceph::HeartbeatMap::~HeartbeatMap()' thread 7f320ce61b80 time 2017-07-12 09:34:47.422986 /home/xxg/build/ceph-dev/src/common/HeartbeatMap.cc: 39: FAILED assert(m_workers.empty()) ceph version 12.1.0-702-gc5b99af (c5b99af) luminous (rc) 1: (ceph::__ceph_assert_fail(char const*, char const*, int, char const*)+0x110) [0x7f320d8ba7f0] 2: (ceph::HeartbeatMap::~HeartbeatMap()+0xf8) [0x7f320d9be0a8] 3: (CephContext::~CephContext()+0x40c) [0x7f320d9a648c] 4: (CephContext::put()+0xe6) [0x7f320d9a6776] 5: (main()+0xad3) [0x7f320d282953] 6: (__libc_start_main()+0xf5) [0x7f32094cfb15] 7: (()+0x4964c9) [0x7f320d31f4c9] NOTE: a copy of the executable, or `objdump -rdS ` is needed to interpret this. Signed-off-by: xie xingguo --- diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 0e0b6ba25ec6..eeb5bc5d8480 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -2568,9 +2568,11 @@ int OSD::init() r = monc->authenticate(); if (r < 0) { + derr << __func__ << " authentication failed: " << cpp_strerror(r) + << dendl; osd_lock.Lock(); // locker is going to unlock this on function exit if (is_stopping()) - r = 0; + r = 0; goto monout; } @@ -2578,9 +2580,10 @@ int OSD::init() derr << "unable to obtain rotating service keys; retrying" << dendl; ++rotating_auth_attempts; if (rotating_auth_attempts > g_conf->max_rotating_auth_attempts) { + derr << __func__ << " wait_auth_rotating timed out" << dendl; osd_lock.Lock(); // make locker happy if (!is_stopping()) { - r = - ETIMEDOUT; + r = -ETIMEDOUT; } goto monout; } @@ -2588,12 +2591,16 @@ int OSD::init() r = update_crush_device_class(); if (r < 0) { + derr << __func__ <<" unable to update_crush_device_class: " + << cpp_strerror(r) << dendl; osd_lock.Lock(); goto monout; } r = update_crush_location(); if (r < 0) { + derr << __func__ <<" unable to update_crush_location: " + << cpp_strerror(r) << dendl; osd_lock.Lock(); goto monout; } @@ -2629,8 +2636,7 @@ int OSD::init() return 0; monout: - mgrc.shutdown(); - monc->shutdown(); + exit(1); out: enable_disable_fuse(true);