-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(restore): batch, scale batch size with shard count This was the initial design, that was changed during implementation by mistake. We should always send shard_cnt * --batch-size sstables in a single restore job, even when user wants to restore into a running cluster. For this case, it should be enough to set --parallel=1 and --batch-size=1 for a slow running restore. * feat(restore): batch, introduce 5% batching for --batch-size=0 This commit allows to set --batch-size=0. When this happens, batches will be created so that they contain about 5% of expected node workload during restore. This allows for creating big, yet evenly distributed batches without the need to play with the --batch-size flag. It should also work better fine when backed up cluster had different amount of nodes than the restore destination cluster. Fixes #4059 * feat(docs): restore, add --batch-size=0 description * fix(restore): batch, remove panics and improve safety * feat(scyllaclient): return error on 0 host shard count This shouldn't be possible, but we can still validate that. * feat(restore): log host shard count * feat(restore): batch, order sstables by size This results in creating batches of sstables of more similar size. Fixes #3979 * feat(restore): extend batch with small leftovers This allows not to bother with small, badly distributed over shards leftover batches. * feat(restore): batch, add test for simple batching scenario
- Loading branch information
1 parent
ddd3cbf
commit 78982d3
Showing
9 changed files
with
257 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
// Copyright (C) 2024 ScyllaDB | ||
|
||
package restore | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/scylladb/scylla-manager/v3/pkg/service/backup/backupspec" | ||
) | ||
|
||
func TestBatchDispatcher(t *testing.T) { | ||
l1 := backupspec.Location{ | ||
Provider: "s3", | ||
Path: "l1", | ||
} | ||
l2 := backupspec.Location{ | ||
Provider: "s3", | ||
Path: "l2", | ||
} | ||
workload := []LocationWorkload{ | ||
{ | ||
Location: l1, | ||
Size: 170, | ||
Tables: []TableWorkload{ | ||
{ | ||
Size: 60, | ||
RemoteDirs: []RemoteDirWorkload{ | ||
{ | ||
RemoteSSTableDir: "a", | ||
Size: 20, | ||
SSTables: []RemoteSSTable{ | ||
{Size: 5}, | ||
{Size: 15}, | ||
}, | ||
}, | ||
{ | ||
RemoteSSTableDir: "e", | ||
Size: 10, | ||
SSTables: []RemoteSSTable{ | ||
{Size: 2}, | ||
{Size: 4}, | ||
{Size: 4}, | ||
}, | ||
}, | ||
{ | ||
RemoteSSTableDir: "b", | ||
Size: 30, | ||
SSTables: []RemoteSSTable{ | ||
{Size: 10}, | ||
{Size: 20}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
Size: 110, | ||
RemoteDirs: []RemoteDirWorkload{ | ||
{ | ||
RemoteSSTableDir: "c", | ||
Size: 110, | ||
SSTables: []RemoteSSTable{ | ||
{Size: 50}, | ||
{Size: 60}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
Location: l2, | ||
Size: 200, | ||
Tables: []TableWorkload{ | ||
{ | ||
Size: 200, | ||
RemoteDirs: []RemoteDirWorkload{ | ||
{ | ||
RemoteSSTableDir: "d", | ||
Size: 200, | ||
SSTables: []RemoteSSTable{ | ||
{Size: 110}, | ||
{Size: 90}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
locationHosts := map[backupspec.Location][]string{ | ||
l1: {"h1", "h2"}, | ||
l2: {"h3"}, | ||
} | ||
hostToShard := map[string]uint{ | ||
"h1": 1, | ||
"h2": 2, | ||
"h3": 3, | ||
} | ||
|
||
bd := newBatchDispatcher(workload, 1, hostToShard, locationHosts) | ||
|
||
scenario := []struct { | ||
host string | ||
ok bool | ||
dir string | ||
size int64 | ||
count int | ||
}{ | ||
{host: "h1", ok: true, dir: "c", size: 60, count: 1}, | ||
{host: "h1", ok: true, dir: "c", size: 50, count: 1}, | ||
{host: "h2", ok: true, dir: "b", size: 30, count: 2}, | ||
{host: "h3", ok: true, dir: "d", size: 200, count: 2}, | ||
{host: "h3", ok: false}, | ||
{host: "h2", ok: true, dir: "a", size: 20, count: 2}, | ||
{host: "h2", ok: true, dir: "e", size: 10, count: 3}, // batch extended with leftovers < shard_cnt | ||
{host: "h1", ok: false}, | ||
{host: "h2", ok: false}, | ||
} | ||
|
||
for _, step := range scenario { | ||
b, ok := bd.DispatchBatch(step.host) | ||
if ok != step.ok { | ||
t.Fatalf("Step: %+v, expected ok=%v, got ok=%v", step, step.ok, ok) | ||
} | ||
if ok == false { | ||
continue | ||
} | ||
if b.RemoteSSTableDir != step.dir { | ||
t.Fatalf("Step: %+v, expected dir=%v, got dir=%v", step, step.dir, b.RemoteSSTableDir) | ||
} | ||
if b.Size != step.size { | ||
t.Fatalf("Step: %+v, expected size=%v, got size=%v", step, step.size, b.Size) | ||
} | ||
if len(b.SSTables) != step.count { | ||
t.Fatalf("Step: %+v, expected count=%v, got count=%v", step, step.count, len(b.SSTables)) | ||
} | ||
} | ||
|
||
if err := bd.ValidateAllDispatched(); err != nil { | ||
t.Fatalf("Expected sstables to be batched: %s", err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters