From d17bd8b93884d24712853779e0cb98ac650b41d3 Mon Sep 17 00:00:00 2001 From: Martin Hutchinson Date: Mon, 19 May 2025 15:10:17 +0000 Subject: [PATCH] [Hammer] Make failed leaves be stickier Previously if a leaf failed on a write, we would discard it and try again with another leaf. This was useful in the event that we generated an invalid leaf, because it would be temporary and the worker could continue. But in reality, we don't generate invalid leaves. So what happened is that in the event of the log temporarily pushing back to the user, leaves would be dropped. This meant that the tree size could be much smaller than the seed index that any indices that leaves had been generated from. All of this meant that on restarting the hammer against a populated log, it could spend a long time resubmitting duplicates because of this index mismatch. This is still possible, but the drift is much smaller now (at most N indices are leaked per hammer run, where N is the number of write workers). --- internal/hammer/loadtest/workers.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/hammer/loadtest/workers.go b/internal/hammer/loadtest/workers.go index 275a2cbbc..7ba1646d8 100644 --- a/internal/hammer/loadtest/workers.go +++ b/internal/hammer/loadtest/workers.go @@ -200,13 +200,13 @@ func (w *LogWriter) Run(ctx context.Context) { panic("LogWriter was run multiple times") } ctx, w.cancel = context.WithCancel(ctx) + newLeaf := w.gen() for { select { case <-ctx.Done(): return case <-w.throttle: } - newLeaf := w.gen() lt := LeafTime{QueuedAt: time.Now()} index, err := w.writer(ctx, newLeaf) if err != nil { @@ -221,6 +221,7 @@ func (w *LogWriter) Run(ctx context.Context) { default: } klog.V(2).Infof("Wrote leaf at index %d", index) + newLeaf = w.gen() } }