Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,11 @@ func shardTableClients(tableClients []tableClient, shard *shard) []tableClient {
return nil
}
if len(chunks) > total && num == total {
return append(chunks[num-1], chunks[num]...)
chunkReturn := chunks[num-1]
for _, chunk := range chunks[total:] {
chunkReturn = append(chunkReturn, chunk...)
}
return chunkReturn
}
return chunks[num-1]
}
45 changes: 45 additions & 0 deletions scheduler/scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,51 @@ func Test_shardTableClients(t *testing.T) {
{client: &testExecutionClient{}, table: &schema.Table{Name: "table_5"}},
},
},

{
name: "uneven split 1 of 3",
tableClients: []tableClient{
{client: &testExecutionClient{}, table: &schema.Table{Name: "table_1"}},
{client: &testExecutionClient{}, table: &schema.Table{Name: "table_2"}},
{client: &testExecutionClient{}, table: &schema.Table{Name: "table_3"}},
{client: &testExecutionClient{}, table: &schema.Table{Name: "table_4"}},
{client: &testExecutionClient{}, table: &schema.Table{Name: "table_5"}},
},
shard: &shard{num: 1, total: 3},
expected: []tableClient{
{client: &testExecutionClient{}, table: &schema.Table{Name: "table_1"}},
},
},
{
name: "uneven split 2 of 3",
tableClients: []tableClient{
{client: &testExecutionClient{}, table: &schema.Table{Name: "table_1"}},
{client: &testExecutionClient{}, table: &schema.Table{Name: "table_2"}},
{client: &testExecutionClient{}, table: &schema.Table{Name: "table_3"}},
{client: &testExecutionClient{}, table: &schema.Table{Name: "table_4"}},
{client: &testExecutionClient{}, table: &schema.Table{Name: "table_5"}},
},
shard: &shard{num: 2, total: 3},
expected: []tableClient{
{client: &testExecutionClient{}, table: &schema.Table{Name: "table_2"}},
},
},
{
name: "uneven split 3 of 3",
tableClients: []tableClient{
{client: &testExecutionClient{}, table: &schema.Table{Name: "table_1"}},
{client: &testExecutionClient{}, table: &schema.Table{Name: "table_2"}},
{client: &testExecutionClient{}, table: &schema.Table{Name: "table_3"}},
{client: &testExecutionClient{}, table: &schema.Table{Name: "table_4"}},
{client: &testExecutionClient{}, table: &schema.Table{Name: "table_5"}},
},
shard: &shard{num: 3, total: 3},
expected: []tableClient{
{client: &testExecutionClient{}, table: &schema.Table{Name: "table_3"}},
{client: &testExecutionClient{}, table: &schema.Table{Name: "table_4"}},
Comment on lines +620 to +621
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prior to this PR, only table_3 and table_4 would have been synced in shard 3/3 and table_5 would never have been synced

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I proposed an alternative in #2163 where the clients are distributed evenly across shards, while also preventing any from being dropped.

{client: &testExecutionClient{}, table: &schema.Table{Name: "table_5"}},
},
},
{
name: "more shards than table clients",
tableClients: []tableClient{
Expand Down
Loading