Skip to content

Commit

Permalink
Merge pull request #9022 from yehudasa/wip-rgw-leak-3-jewel
Browse files Browse the repository at this point in the history
jewel: rgw: leak fixes
  • Loading branch information
yehudasa committed May 10, 2016
2 parents 80beeff + 5fdca84 commit 8bbe2a9
Show file tree
Hide file tree
Showing 12 changed files with 327 additions and 85 deletions.
13 changes: 7 additions & 6 deletions src/rgw/rgw_civetweb_frontend.cc
Expand Up @@ -8,17 +8,18 @@
static int civetweb_callback(struct mg_connection* conn) {
struct mg_request_info* req_info = mg_get_request_info(conn);
RGWMongooseEnv* pe = static_cast<RGWMongooseEnv *>(req_info->user_data);
RGWRados* store = pe->store;
RGWREST* rest = pe->rest;
OpsLogSocket* olog = pe->olog;

RGWRequest req(store->get_new_req_id());
RGWMongoose client_io(conn, pe->port);

{
// hold a read lock over access to pe->store for reconfiguration
RWLock::RLocker lock(pe->mutex);

RGWRados* store = pe->store;
RGWREST* rest = pe->rest;
OpsLogSocket* olog = pe->olog;

RGWRequest req(store->get_new_req_id());
RGWMongoose client_io(conn, pe->port);

int ret = process_request(pe->store, rest, &req, &client_io, olog);
if (ret < 0) {
/* we don't really care about return code */
Expand Down
3 changes: 3 additions & 0 deletions src/rgw/rgw_cr_rados.cc
Expand Up @@ -309,6 +309,7 @@ void RGWSimpleRadosLockCR::request_cleanup()
{
if (req) {
req->finish();
req = NULL;
}
}

Expand Down Expand Up @@ -345,6 +346,7 @@ void RGWSimpleRadosUnlockCR::request_cleanup()
{
if (req) {
req->finish();
req = NULL;
}
}

Expand Down Expand Up @@ -639,6 +641,7 @@ void RGWStatObjCR::request_cleanup()
{
if (req) {
req->finish();
req = NULL;
}
}

Expand Down
45 changes: 44 additions & 1 deletion src/rgw/rgw_cr_rados.h
Expand Up @@ -196,10 +196,14 @@ class RGWSimpleRadosReadCR : public RGWSimpleCoroutine {
pattrs(NULL),
result(_result),
req(NULL) { }
~RGWSimpleRadosReadCR() {
request_cleanup();
}

void request_cleanup() {
if (req) {
req->finish();
req = NULL;
}
}

Expand Down Expand Up @@ -270,10 +274,14 @@ class RGWSimpleRadosReadAttrsCR : public RGWSimpleCoroutine {
pool(_pool), oid(_oid),
pattrs(_pattrs),
req(NULL) { }
~RGWSimpleRadosReadAttrsCR() {
request_cleanup();
}

void request_cleanup() {
if (req) {
req->finish();
req = NULL;
}
}

Expand Down Expand Up @@ -303,9 +311,14 @@ class RGWSimpleRadosWriteCR : public RGWSimpleCoroutine {
::encode(_data, bl);
}

~RGWSimpleRadosWriteCR() {
request_cleanup();
}

void request_cleanup() {
if (req) {
req->finish();
req = NULL;
}
}

Expand Down Expand Up @@ -342,10 +355,14 @@ class RGWSimpleRadosWriteAttrsCR : public RGWSimpleCoroutine {
pool(_pool), oid(_oid),
attrs(_attrs), req(NULL) {
}
~RGWSimpleRadosWriteAttrsCR() {
request_cleanup();
}

void request_cleanup() {
if (req) {
req->finish();
req = NULL;
}
}

Expand Down Expand Up @@ -429,6 +446,9 @@ class RGWSimpleRadosLockCR : public RGWSimpleCoroutine {
const rgw_bucket& _pool, const string& _oid, const string& _lock_name,
const string& _cookie,
uint32_t _duration);
~RGWSimpleRadosLockCR() {
request_cleanup();
}
void request_cleanup();

int send_request();
Expand All @@ -450,6 +470,9 @@ class RGWSimpleRadosUnlockCR : public RGWSimpleCoroutine {
RGWSimpleRadosUnlockCR(RGWAsyncRadosProcessor *_async_rados, RGWRados *_store,
const rgw_bucket& _pool, const string& _oid, const string& _lock_name,
const string& _cookie);
~RGWSimpleRadosUnlockCR() {
request_cleanup();
}
void request_cleanup();

int send_request();
Expand Down Expand Up @@ -520,11 +543,15 @@ class RGWWaitCR : public RGWSimpleCoroutine {
int _secs) : RGWSimpleCoroutine(cct), cct(_cct),
async_rados(_async_rados), lock(_lock), cond(_cond), secs(_secs), req(NULL) {
}
~RGWWaitCR() {
request_cleanup();
}

void request_cleanup() {
wakeup();
if (req) {
wakeup();
req->finish();
req = NULL;
}
}

Expand Down Expand Up @@ -619,9 +646,13 @@ class RGWGetBucketInstanceInfoCR : public RGWSimpleCoroutine {
RGWBucketInfo *_bucket_info) : RGWSimpleCoroutine(_store->ctx()), async_rados(_async_rados), store(_store),
bucket_name(_bucket_name), bucket_id(_bucket_id),
bucket_info(_bucket_info), req(NULL) {}
~RGWGetBucketInstanceInfoCR() {
request_cleanup();
}
void request_cleanup() {
if (req) {
req->finish();
req = NULL;
}
}

Expand Down Expand Up @@ -696,9 +727,14 @@ class RGWFetchRemoteObjCR : public RGWSimpleCoroutine {
copy_if_newer(_if_newer), req(NULL) {}


~RGWFetchRemoteObjCR() {
request_cleanup();
}

void request_cleanup() {
if (req) {
req->finish();
req = NULL;
}
}

Expand Down Expand Up @@ -810,10 +846,14 @@ class RGWRemoveObjCR : public RGWSimpleCoroutine {
owner_display_name = *_owner_display_name;
}
}
~RGWRemoveObjCR() {
request_cleanup();
}

void request_cleanup() {
if (req) {
req->finish();
req = NULL;
}
}

Expand Down Expand Up @@ -934,6 +974,9 @@ class RGWStatObjCR : public RGWSimpleCoroutine {
const rgw_obj& obj, uint64_t *psize = nullptr,
real_time* pmtime = nullptr, uint64_t *pepoch = nullptr,
RGWObjVersionTracker *objv_tracker = nullptr);
~RGWStatObjCR() {
request_cleanup();
}
void request_cleanup();

int send_request() override;
Expand Down
14 changes: 14 additions & 0 deletions src/rgw/rgw_cr_rest.h
Expand Up @@ -25,6 +25,10 @@ class RGWReadRESTResourceCR : public RGWSimpleCoroutine {
path(_path), params(make_param_list(params)), result(_result)
{}

~RGWReadRESTResourceCR() {
request_cleanup();
}

int send_request() {
auto op = boost::intrusive_ptr<RGWRESTReadResource>(
new RGWRESTReadResource(conn, path, params, NULL, http_manager));
Expand All @@ -35,6 +39,7 @@ class RGWReadRESTResourceCR : public RGWSimpleCoroutine {
if (ret < 0) {
log_error() << "failed to send http operation: " << op->to_str()
<< " ret=" << ret << std::endl;
op->put();
return ret;
}
std::swap(http_op, op); // store reference in http_op on success
Expand All @@ -47,14 +52,17 @@ class RGWReadRESTResourceCR : public RGWSimpleCoroutine {
if (ret < 0) {
error_stream << "http operation failed: " << op->to_str()
<< " status=" << op->get_http_status() << std::endl;
op->put();
return ret;
}
op->put();
return 0;
}

void request_cleanup() {
if (http_op) {
http_op->put();
http_op = NULL;
}
}
};
Expand All @@ -79,6 +87,10 @@ class RGWPostRESTResourceCR : public RGWSimpleCoroutine {
input(_input)
{}

~RGWPostRESTResourceCR() {
request_cleanup();
}

int send_request() {
auto op = boost::intrusive_ptr<RGWRESTPostResource>(
new RGWRESTPostResource(conn, path, params, NULL, http_manager));
Expand Down Expand Up @@ -119,12 +131,14 @@ class RGWPostRESTResourceCR : public RGWSimpleCoroutine {
op->put();
return ret;
}
op->put();
return 0;
}

void request_cleanup() {
if (http_op) {
http_op->put();
http_op = NULL;
}
}
};
Expand Down
15 changes: 13 additions & 2 deletions src/rgw/rgw_data_sync.cc
Expand Up @@ -170,6 +170,8 @@ class RGWReadRemoteDataLogShardCR : public RGWCoroutine {
pmarker(_pmarker),
entries(_entries),
truncated(_truncated) {
}
~RGWReadRemoteDataLogShardCR() {
if (http_op) {
http_op->put();
}
Expand Down Expand Up @@ -476,12 +478,12 @@ int RGWRemoteDataLog::read_source_log_shards_next(map<int, string> shard_markers

int RGWRemoteDataLog::init(const string& _source_zone, RGWRESTConn *_conn, RGWSyncErrorLogger *_error_logger)
{
sync_env.init(store->ctx(), store, _conn, async_rados, &http_manager, _error_logger, _source_zone);

if (initialized) {
return 0;
}

sync_env.init(store->ctx(), store, _conn, async_rados, &http_manager, _error_logger, _source_zone);

int ret = http_manager.set_threaded();
if (ret < 0) {
ldout(store->ctx(), 0) << "failed in http_manager.set_threaded() ret=" << ret << dendl;
Expand Down Expand Up @@ -1354,13 +1356,15 @@ int RGWDataSyncStatusManager::init()
r = source_log.init(source_zone, conn, error_logger);
if (r < 0) {
lderr(store->ctx()) << "ERROR: failed to init remote log, r=" << r << dendl;
finalize();
return r;
}

rgw_datalog_info datalog_info;
r = source_log.read_log_info(&datalog_info);
if (r < 0) {
ldout(store->ctx(), 5) << "ERROR: master.read_log_info() returned r=" << r << dendl;
finalize();
return r;
}

Expand All @@ -1373,6 +1377,13 @@ int RGWDataSyncStatusManager::init()
return 0;
}

void RGWDataSyncStatusManager::finalize()
{
delete error_logger;
error_logger = nullptr;
ioctx.close();
}

string RGWDataSyncStatusManager::sync_status_oid(const string& source_zone)
{
char buf[datalog_sync_status_oid_prefix.size() + source_zone.size() + 16];
Expand Down
3 changes: 2 additions & 1 deletion src/rgw/rgw_data_sync.h
Expand Up @@ -242,9 +242,10 @@ class RGWDataSyncStatusManager {
: store(_store), source_zone(_source_zone), conn(NULL), error_logger(NULL),
source_log(store, async_rados), num_shards(0) {}
~RGWDataSyncStatusManager() {
delete error_logger;
finalize();
}
int init();
void finalize();

rgw_data_sync_status& get_sync_status() { return sync_status; }

Expand Down

0 comments on commit 8bbe2a9

Please sign in to comment.