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 committed
May 20, 2019 at 21:31 UTC
06e16acdb01be318a6c5c6bd3a2a49d2f4458dba
1 file changed
+9
-2
database/engine/pagecache.c
+9
-2
@@ -350,8 +350,14 @@ void pg_cache_punch_hole(struct rrdengine_instance *ctx, struct rrdeng_page_cach
350
351
uv_rwlock_wrlock(&page_index->lock);
352
ret = JudyLDel(&page_index->JudyL_array, (Word_t)(descr->start_time / USEC_PER_SEC), PJE0);
353
- assert(1 == ret);
353
uv_rwlock_wrunlock(&page_index->lock);
354
+ if (unlikely(0 == ret)) {
355
+ error("Page under deletion was not in index.");
356
+ if (unlikely(debug_flags & D_RRDENGINE))
357
+ print_page_cache_descr(descr);
358
+ goto destroy;
359
+ }
360
+ assert(1 == ret);
361
362
uv_rwlock_wrlock(&pg_cache->pg_cache_rwlock);
363
++ctx->stats.pg_cache_deletions;
@@ -368,7 +374,7 @@ void pg_cache_punch_hole(struct rrdengine_instance *ctx, struct rrdeng_page_cach
374
/* even a locked page could be dirty */
375
while (unlikely(descr->flags & RRD_PAGE_DIRTY)) {
376
debug(D_RRDENGINE, "%s: Found dirty page, waiting for it to be flushed:", __func__);
371
- if(unlikely(debug_flags & D_RRDENGINE))
377
+ if (unlikely(debug_flags & D_RRDENGINE))
378
print_page_cache_descr(descr);
379
pg_cache_wait_event_unsafe(descr);
380
}
@@ -383,6 +389,7 @@ void pg_cache_punch_hole(struct rrdengine_instance *ctx, struct rrdeng_page_cach
389
uv_rwlock_wrunlock(&pg_cache->pg_cache_rwlock);
390
}
391
pg_cache_put(descr);
392
+destroy:
393
pg_cache_destroy_descr(descr);
394
pg_cache_update_metric_times(page_index);
395
}