Browse Source

Fix delete datafile error (#6057)

* Added print to debug failure to delete page during datafile deletion

* Detect case of corrupted pages not being in page cache when deleting file
Markos Fountoulakis 5 years ago
parent
commit
06e16acdb0
1 changed files with 9 additions and 2 deletions
  1. 9 2
      database/engine/pagecache.c

+ 9 - 2
database/engine/pagecache.c

@@ -350,8 +350,14 @@ void pg_cache_punch_hole(struct rrdengine_instance *ctx, struct rrdeng_page_cach
 
     uv_rwlock_wrlock(&page_index->lock);
     ret = JudyLDel(&page_index->JudyL_array, (Word_t)(descr->start_time / USEC_PER_SEC), PJE0);
-    assert(1 == ret);
     uv_rwlock_wrunlock(&page_index->lock);
+    if (unlikely(0 == ret)) {
+        error("Page under deletion was not in index.");
+        if (unlikely(debug_flags & D_RRDENGINE))
+            print_page_cache_descr(descr);
+        goto destroy;
+    }
+    assert(1 == ret);
 
     uv_rwlock_wrlock(&pg_cache->pg_cache_rwlock);
     ++ctx->stats.pg_cache_deletions;
@@ -368,7 +374,7 @@ void pg_cache_punch_hole(struct rrdengine_instance *ctx, struct rrdeng_page_cach
     /* even a locked page could be dirty */
     while (unlikely(descr->flags & RRD_PAGE_DIRTY)) {
         debug(D_RRDENGINE, "%s: Found dirty page, waiting for it to be flushed:", __func__);
-        if(unlikely(debug_flags & D_RRDENGINE))
+        if (unlikely(debug_flags & D_RRDENGINE))
             print_page_cache_descr(descr);
         pg_cache_wait_event_unsafe(descr);
     }
@@ -383,6 +389,7 @@ void pg_cache_punch_hole(struct rrdengine_instance *ctx, struct rrdeng_page_cach
         uv_rwlock_wrunlock(&pg_cache->pg_cache_rwlock);
     }
     pg_cache_put(descr);
+destroy:
     pg_cache_destroy_descr(descr);
     pg_cache_update_metric_times(page_index);
 }