-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
crud: fix explicit bucket_id in *_many operations
In case `insert_many`, `insert_object_many`, `replace_many`, `replace_object_many`, `upsert_many` or `upsert_object_many` has been called on a space with custom sharding info and every tuple/object in the request had `bucket_id`, `ShardingHashMismatchError` has been returned even though there are no issues with sharding info. For example, some users met this issue while working with tt-ee `tt crud import` command. The reason is as follows. To ensure sharding info consistency between the storage and the router, some metainfo is calculated for a request in case bucket_id is generated. In case no bucket_id is generated, no sharding info is passed and consistency check is skipped (since it is not needed). Before this patch, `*_many` operations haven't skipped consistency check when it was expected due to improper `skip_sharding_hash_check` flag setup. Closes #437
- Loading branch information
1 parent
435b61e
commit 9c1b02e
Showing
7 changed files
with
196 additions
and
6 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
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,62 @@ | ||
local t = require('luatest') | ||
local checks = require('checks') | ||
|
||
-- Scenario is for 'srv_batch_operations' entrypoint. | ||
local function gh_437_many_explicit_bucket_ids(cg, operation, opts) | ||
checks('table', 'string', { | ||
objects = '?boolean', | ||
upsert = '?boolean', | ||
partial_explicit_bucket_ids = '?boolean', | ||
}) | ||
|
||
opts = opts or {} | ||
|
||
local rows = { | ||
{1, 1, 'Kumiko', 18}, | ||
{2, 2, 'Reina', 19}, | ||
{3, 3, 'Shuuichi', 18}, | ||
} | ||
|
||
if opts.partial_explicit_bucket_ids then | ||
rows[2][2] = box.NULL | ||
end | ||
|
||
local objects = {} | ||
for k, v in ipairs(rows) do | ||
objects[k] = {id = v[1], bucket_id = v[2], name = v[3], age = v[4]} | ||
end | ||
|
||
local data | ||
if opts.objects then | ||
data = objects | ||
else | ||
data = rows | ||
end | ||
|
||
if opts.upsert then | ||
local update_operations = {} | ||
for k, v in ipairs(data) do | ||
data[k] = {v, update_operations} | ||
end | ||
end | ||
|
||
local args = {'customers_sharded_by_age', data} | ||
|
||
local result, errs = cg.router:call('crud.' .. operation, args) | ||
t.assert_equals(errs, nil) | ||
|
||
local result_rows = table.deepcopy(rows) | ||
if opts.partial_explicit_bucket_ids then | ||
result_rows[2][2] = 1325 | ||
end | ||
if opts.upsert then | ||
-- upsert never return anything. | ||
t.assert_equals(result.rows, nil) | ||
else | ||
t.assert_items_equals(result.rows, result_rows) | ||
end | ||
end | ||
|
||
return { | ||
gh_437_many_explicit_bucket_ids = gh_437_many_explicit_bucket_ids, | ||
} |