Skip to content

Commit

Permalink
(#546) Fix the segmentation fault after splinterdb_stats_reset() (#547)
Browse files Browse the repository at this point in the history
Previously, when trunk_stats_reset() was called by
splinterdb_stats_reset(), the entire statistics of a trunk, including
the histogram handles, were reset to zero.
  • Loading branch information
deukyeon authored Apr 25, 2023
1 parent fa990cf commit 1e8f790
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/trunk.c
Original file line number Diff line number Diff line change
Expand Up @@ -9157,7 +9157,33 @@ void
trunk_reset_stats(trunk_handle *spl)
{
if (spl->cfg.use_stats) {
memset(spl->stats, 0, MAX_THREADS * sizeof(trunk_stats));
for (threadid thr_i = 0; thr_i < MAX_THREADS; thr_i++) {
platform_histo_destroy(spl->heap_id,
spl->stats[thr_i].insert_latency_histo);
platform_histo_destroy(spl->heap_id,
spl->stats[thr_i].update_latency_histo);
platform_histo_destroy(spl->heap_id,
spl->stats[thr_i].delete_latency_histo);

memset(&spl->stats[thr_i], 0, sizeof(spl->stats[thr_i]));

platform_status rc;
rc = platform_histo_create(spl->heap_id,
LATENCYHISTO_SIZE + 1,
latency_histo_buckets,
&spl->stats[thr_i].insert_latency_histo);
platform_assert_status_ok(rc);
rc = platform_histo_create(spl->heap_id,
LATENCYHISTO_SIZE + 1,
latency_histo_buckets,
&spl->stats[thr_i].update_latency_histo);
platform_assert_status_ok(rc);
rc = platform_histo_create(spl->heap_id,
LATENCYHISTO_SIZE + 1,
latency_histo_buckets,
&spl->stats[thr_i].delete_latency_histo);
platform_assert_status_ok(rc);
}
}
}

Expand Down

0 comments on commit 1e8f790

Please sign in to comment.