]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd: fix leaks of ObjectContext in the registry. 44008/head
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Tue, 16 Nov 2021 01:35:12 +0000 (01:35 +0000)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Thu, 18 Nov 2021 17:40:52 +0000 (17:40 +0000)
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>
src/crimson/osd/object_context.cc
src/crimson/osd/object_context.h

index bbc71d3f9a439b412a16a73fce89b84d1aec6682..5ecc184f31fabf25234ceb6366f3e6b7f419288b 100644 (file)
@@ -14,6 +14,12 @@ ObjectContextRegistry::ObjectContextRegistry(crimson::common::ConfigProxy &conf)
   conf.add_observer(this);
 }
 
+ObjectContextRegistry::~ObjectContextRegistry()
+{
+  // purge the cache to avoid leaks and complains from LSan
+  obc_lru.set_target_size(0UL);
+}
+
 const char** ObjectContextRegistry::get_tracked_conf_keys() const
 {
   static const char* KEYS[] = {
index f1613564e8c1bf33f8e36c2bb58a43f012a76f54..d5165dc23e814b93a94d11875a8b418d6d5865f0 100644 (file)
@@ -234,6 +234,7 @@ class ObjectContextRegistry : public md_config_obs_t  {
 
 public:
   ObjectContextRegistry(crimson::common::ConfigProxy &conf);
+  ~ObjectContextRegistry();
 
   std::pair<ObjectContextRef, bool> get_cached_obc(const hobject_t &hoid) {
     return obc_lru.get_or_create(hoid);