Skip to content

Commit

Permalink
fix(wal/benchmark): stop to trim before close the wal
Browse files Browse the repository at this point in the history
Signed-off-by: Ning Yu <[email protected]>
  • Loading branch information
Chillax-0v0 committed Jan 2, 2024
1 parent ba1fd85 commit d8785cd
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ private void run(Config config) {
config.threads, ThreadUtils.createThreadFactory("append-thread-%d", false), null);
AppendTaskConfig appendTaskConfig = new AppendTaskConfig(config);
Stat stat = new Stat();
runTrimTask();
Runnable stopTrim = runTrimTask();
for (int i = 0; i < config.threads; i++) {
int index = i;
executor.submit(() -> {
Expand All @@ -152,11 +152,12 @@ private void run(Config config) {
} catch (InterruptedException e) {
executor.shutdownNow();
}
stopTrim.run();

System.out.println("Benchmark finished");
}

private void runTrimTask() {
private Runnable runTrimTask() {
ScheduledExecutorService trimExecutor = Threads.newSingleThreadScheduledExecutor(
ThreadUtils.createThreadFactory("trim-thread-%d", true), null);
trimExecutor.scheduleAtFixedRate(() -> {
Expand All @@ -167,6 +168,7 @@ private void runTrimTask() {
e.printStackTrace();
}
}, TRIM_INTERVAL_MILLIS, TRIM_INTERVAL_MILLIS, TimeUnit.MILLISECONDS);
return trimExecutor::shutdownNow;
}

private void runAppendTask(int index, AppendTaskConfig config, Stat stat) throws Exception {
Expand Down

0 comments on commit d8785cd

Please sign in to comment.