From f8200a638692b8833bceba5cdbbc2f110cc4f3f7 Mon Sep 17 00:00:00 2001 From: Christian Schwarz Date: Thu, 2 Jan 2020 14:29:02 +0100 Subject: [PATCH] replication/driver: regulate per-filesystem step planning through stepQueue before this patch, we'd have unbounded parallelism for ListFilesystemVersions RPCs --- replication/driver/replication_driver.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/replication/driver/replication_driver.go b/replication/driver/replication_driver.go index 0c1cd8f..a9c2ce7 100644 --- a/replication/driver/replication_driver.go +++ b/replication/driver/replication_driver.go @@ -371,9 +371,21 @@ func (a *attempt) do(ctx context.Context, prev *attempt) { } func (fs *fs) do(ctx context.Context, pq *stepQueue, prev *fs) { - psteps, err := fs.fs.PlanFS(ctx) - errTime := time.Now() + defer fs.l.Lock().Unlock() + + // get planned steps from replication logic + var psteps []Step + var errTime time.Time + var err error + fs.l.DropWhile(func() { + // TODO hacky + // choose target time that is earlier than any snapshot, so fs planning is always prioritized + targetDate := time.Unix(0, 0) + defer pq.WaitReady(fs, targetDate)() + psteps, err = fs.fs.PlanFS(ctx) // no shadow + errTime = time.Now() // no shadow + }) debug := debugPrefix("fs=%s", fs.fs.ReportInfo().Name) fs.planning.done = true if err != nil {