Skip to content

Commit bf3c3bb

Browse files
feat(restore): extend batch with small leftovers
This allows not to bother with small, badly distributed over shards leftover batches.
1 parent ac72b54 commit bf3c3bb

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pkg/service/restore/batch.go

+7
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,13 @@ func (b *batchDispatcher) createBatch(l *LocationWorkload, t *TableWorkload, dir
207207
if i == 0 {
208208
return batch{}, false
209209
}
210+
// Extend batch if it was to leave less than
211+
// 1 sstable per shard for the next one.
212+
if len(dir.SSTables)-i < int(shardCnt) {
213+
for ; i < len(dir.SSTables); i++ {
214+
size += dir.SSTables[i].Size
215+
}
216+
}
210217

211218
sstables := dir.SSTables[:i]
212219
dir.SSTables = dir.SSTables[i:]

0 commit comments

Comments
 (0)