Skip to content

Commit

Permalink
Merge pull request #73757 from cockroachdb/blathers/backport-release-…
Browse files Browse the repository at this point in the history
…21.1-73705

release-21.1: bulk: add pre-flush delay setting
  • Loading branch information
dt committed Dec 13, 2021
2 parents 0783bba + eed1b9c commit 67f295e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions pkg/kv/bulk/sst_batcher.go
Expand Up @@ -36,6 +36,13 @@ var (
"size below which a 'bulk' write will be performed as a normal write instead",
400*1<<10, // 400 Kib
)

ingestDelay = settings.RegisterDurationSetting(
"bulkio.ingest.flush_delay",
"amount of time to wait before sending a file to the KV/Storage layer to ingest",
0,
settings.NonNegativeDuration,
)
)

type sz int64
Expand Down Expand Up @@ -264,6 +271,17 @@ func (b *SSTBatcher) doFlush(ctx context.Context, reason int, nextKey roachpb.Ke
}
b.flushCounts.total++

if delay := ingestDelay.Get(&b.settings.SV); delay != 0 {
if delay > time.Second || log.V(1) {
log.Infof(ctx, "delaying %s before flushing ingestion buffer...", delay)
}
select {
case <-ctx.Done():
return ctx.Err()
case <-time.After(delay):
}
}

hour := hlc.Timestamp{WallTime: timeutil.Now().Add(time.Hour).UnixNano()}

start := roachpb.Key(append([]byte(nil), b.batchStartKey...))
Expand Down

0 comments on commit 67f295e

Please sign in to comment.