Skip to content

rgw: fix rgw hang when do RGWRealmReloader::reload after go SIGHUP - #16417

Merged
yuriw merged 1 commit into
ceph:masterfrom
fangyuxiangGL:rgw-hang
Jul 24, 2017
Merged

yuriw merged 1 commit into
ceph:masterfrom
fangyuxiangGL:rgw-hang

Conversation

@fangyuxiangGL

@fangyuxiangGL fangyuxiangGL commented Jul 19, 2017 •

Copy link
Copy Markdown
Contributor

pendings in RGWGetBucketStatsContext is initialized to zero when rgw_override_bucket_index_max_shards is zero.

so --pendings will got 0xffffffff, which lead async_refcount not put correctly, then the thread handle RGWRealmReloader::reload will hang, then cause request process worker thread of rgw frontend hang(the write lock was held by RGWRealmReloader::reload handle thread, but request process worker thread need to get read lock)

the procedure of quota fetch is a bit tricky and worse, this fix is not perfect, but is better with minimum changes

http://tracker.ceph.com/issues/20686

@fangyuxiangGL

Copy link
Copy Markdown
Contributor Author

@cbodley please have a look, thanks!

@mattbenjamin mattbenjamin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks promising, defer to one of the multisite folks for approval

@cbodley cbodley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, thanks. can you expand a bit on the other issues with quota fetch?

@fangyuxiangGL

fangyuxiangGL commented Jul 19, 2017 •

Copy link
Copy Markdown
Contributor Author

@cbodley

Just issue with low possibility that will cause quota stats incorrect. please have a look at codes below:

int RGWRados::get_bucket_stats_async(RGWBucketInfo& bucket_info,
int shard_id, RGWGetBucketStats_CB *ctx)
{
int num_aio = 0;
RGWGetBucketStatsContext *get_ctx = new
RGWGetBucketStatsContext(ctx, bucket_info.num_shards);
assert(get_ctx);
int r = cls_bucket_head_async(bucket_info, shard_id, get_ctx, &num_aio);
get_ctx->put();
if (r < 0) {
ctx->put();
if (num_aio) {
get_ctx->unset_cb(); may race with the async io callback sent in cls_bucket_head_async
}
}
return r;
}`

@cbodley

cbodley commented Jul 19, 2017

Copy link
Copy Markdown
Contributor

get_ctx->unset_cb(); may race with the async io callback sent in cls_bucket_head_async

thanks, looks like you're right. it also accesses get_ctx after it called get_ctx->put() above

@fangyuxiangGL

fangyuxiangGL commented Jul 19, 2017 •

Copy link
Copy Markdown
Contributor Author

you are right, so race result:

  1. if part of async io sent was called back before get_ctx->unset_cb(), bucket quota stats will be incorrect
  2. if all of async io sent was called back before get_ctx->unset_cb(), rgw will crash

@cbodley

cbodley commented Jul 19, 2017

Copy link
Copy Markdown
Contributor

@fangyuxiangGL could you move that call to get_ctx->put() down below the if (r < 0) {} block? we might as well fix and backport that at the same time

@fangyuxiangGL

Copy link
Copy Markdown
Contributor Author

@cbodley

moved get_ctx->put() down

@fangyuxiangGL
fangyuxiangGL force-pushed the rgw-hang branch 3 times, most recently from 838fe89 to 9571609 Compare July 20, 2017 03:01
@fangyuxiangGL

fangyuxiangGL commented Jul 20, 2017 •

Copy link
Copy Markdown
Contributor Author

I am wrong with saying that "if part of async io sent was called back before get_ctx->unset_cb(), bucket quota stats will be incorrect"; in fact, every async io only update its temp stats and only calculated totally when (pendings == 0).

But there is an issue when exception happened, considered that pengdings == 0 and retcode < 0(real fail from rados cluster, not early fail) when code reach here:

if (--pendings == 0) { if (!ret_code) { cb->set_response(&stats); } cb->handle_response(ret_code); cb->put(); }

then cb->handle_response follow in:

void BucketAsyncRefreshHandler::handle_response(const int r)
{
if (r < 0) { early return without call async_refcount->put()
ldout(store->ctx(), 20) << "AsyncRefreshHandler::handle_response() r=" << r << dendl;
return; /* nothing to do here */
}

RGWStorageStats bs;

for (const auto& pair : *stats) {
const RGWStorageStats& s = pair.second;

bs.size += s.size;
bs.size_rounded += s.size_rounded;
bs.num_objects += s.num_objects;

}

cache->async_refresh_response(user, bucket, bs);
}

i introduced async_refresh_fail to RGWQuotaCache, and should be called when got error response, it just put the reference without update the quota stats.

@cbodley, now it's very pleased to hear your opinions, thanks!

@cbodley

cbodley commented Jul 20, 2017

Copy link
Copy Markdown
Contributor

i introduced async_refresh_fail to RGWQuotaCache, and should be called when got error response, it just put the reference without update the quota stats.

thanks for the explanation, the async_refresh_fail() changes looks good 👍

@cbodley

cbodley commented Jul 20, 2017

Copy link
Copy Markdown
Contributor

jenkins test this please

@yuriw
yuriw merged commit b4c42f3 into ceph:master Jul 24, 2017
@fangyuxiangGL
fangyuxiangGL deleted the rgw-hang branch January 10, 2018 03:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants