Skip to content

Commit 9ae3774

Browse files
committed
crimson/osd: fix leaks of ObjectContext in the registry.
The patch is supposed to fix the following problems (extra debugs onboard): ``` NFO 2021-11-16 01:18:38,713 [shard 0] osd - ~OSD: OSD dtor called INFO 2021-11-16 01:18:38,713 [shard 0] osd - Heartbeat::Peer: osd.6 removed INFO 2021-11-16 01:18:38,714 [shard 0] osd - Heartbeat::Peer: osd.5 removed INFO 2021-11-16 01:18:38,714 [shard 0] osd - Heartbeat::Peer: osd.2 removed INFO 2021-11-16 01:18:38,714 [shard 0] osd - ~ShardServices: ShardServices dtor called INFO 2021-11-16 01:18:38,714 [shard 0] osd - ~ObjectContextRegistry: ShardServices dtor called; unref_size=3, size=3 INFO 2021-11-16 01:18:38,714 [shard 0] osd - ~ObjectContextRegistry: unreferenced p=0x619000115380 INFO 2021-11-16 01:18:38,714 [shard 0] osd - ~ObjectContextRegistry: unreferenced p=0x619000114980 INFO 2021-11-16 01:18:38,714 [shard 0] osd - ~ObjectContextRegistry: unreferenced p=0x619000112680 INFO 2021-11-16 01:18:38,714 [shard 0] osd - ~ObjectContextRegistry: set p=0x619000114980 INFO 2021-11-16 01:18:38,714 [shard 0] osd - ~ObjectContextRegistry: set p=0x619000115380 INFO 2021-11-16 01:18:38,714 [shard 0] osd - ~ObjectContextRegistry: set p=0x619000112680 INFO 2021-11-16 01:18:38,738 [shard 0] osd - crimson shutdown complete ================================================================= ==33351==ERROR: LeakSanitizer: detected memory leaks Direct leak of 2808 byte(s) in 3 object(s) allocated from: #0 0x7fe10c0327b0 in operator new(unsigned long) (/lib64/libasan.so.5+0xf17b0) #1 0x55accbe8ffc4 in ceph::common::intrusive_lru<ceph::common::intrusive_lru_config<hobject_t, crimson::osd::ObjectContext, crimson::osd::obc_to_hoid<crimson::osd::ObjectContext> > >::get_or_create(hobject_t const&) (/usr/bin/ceph-osd+0x3b000fc4) Objects leaked above: 0x619000112680 (936 bytes) 0x619000114980 (936 bytes) 0x619000115380 (936 bytes) ``` Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
1 parent 5e56258 commit 9ae3774

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/crimson/osd/object_context.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ ObjectContextRegistry::ObjectContextRegistry(crimson::common::ConfigProxy &conf)
1414
conf.add_observer(this);
1515
}
1616

17+
ObjectContextRegistry::~ObjectContextRegistry()
18+
{
19+
// purge the cache to avoid leaks and complains from LSan
20+
obc_lru.set_target_size(0UL);
21+
}
22+
1723
const char** ObjectContextRegistry::get_tracked_conf_keys() const
1824
{
1925
static const char* KEYS[] = {

src/crimson/osd/object_context.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ class ObjectContextRegistry : public md_config_obs_t {
234234

235235
public:
236236
ObjectContextRegistry(crimson::common::ConfigProxy &conf);
237+
~ObjectContextRegistry();
237238

238239
std::pair<ObjectContextRef, bool> get_cached_obc(const hobject_t &hoid) {
239240
return obc_lru.get_or_create(hoid);

0 commit comments

Comments
 (0)