Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api: support vshard groups #319

Merged
merged 9 commits into from
Aug 31, 2022

Conversation

DifferentialOrange
Copy link
Member

@DifferentialOrange DifferentialOrange commented Aug 16, 2022

readme: fix args description

changelog: use single format

After discussion with Ecosystem team, we decided not to specify PR in CHANGELOG entries if there is a related issue. This patch make last CHANGELOG entries consistent.

api: deprecate using space id in len

Part of #255

internal: use vshard router object

This patch is the groundwork for vshard groups and custom routers
support.

Test runs have shown that this patch do not affects the performance of
crud requests.

Part of #44

internal: rework replicasets schema reload

This patch is the groundwork for vshard groups and custom routers
support.

After this patch, schema reload works per vshard router object.

Test runs have shown that this patch do not affects the performance of
crud requests.

Part of #44

internal: rework sharding schema reload

This patch is the groundwork for vshard groups and custom routers
support.

After this patch, sharding schema reload works per vshard router object.

Test runs have shown that this patch do not affects the performance of
crud requests.

Part of #44

internal: use single router object

This patch is the groundwork for vshard groups and custom routers
support.

After this patch, vshard router object is retrieved only in the single
point of a request. (Except for name resolving in statistics.)

Test runs have shown that this patch do not affects the performance of
crud requests.

Part of #44

api: support vshard groups

This patch adds Cartridge vshard groups [1] and non-default vshard router [2] support to CRUD operations.

To specify Cartridge vshard group, pass vshard group name with vshard_router option of a crud operation.

crud.select('customers_ddl',
            {{'=', 'age', 41}},
            {vshard_router = 'customers'})

To use non-default vshard router, pass vshard router object with vshard_router option of a crud operation.

local router = vshard.router.new(cfg)

crud.select('customers_ddl',
            {{'=', 'age', 41}},
            {vshard_router = router})

If vshard_router is not specified, default vshard router is used to process the request. If default vshard router is not found (for example, if it is a Cartridge application with vshard groups) and option is not specified, the error is returned.

  1. https://www.tarantool.io/en/doc/latest/book/cartridge/cartridge_dev/#using-multiple-vshard-storage-groups
  2. https://www.tarantool.io/ru/doc/latest/reference/reference_rock/vshard/vshard_router/#router-api-new

Closes #44

stats: warn for using id with custom router

CRUD stats are separated by space name. If space id is passed instead of name (only crud.len allows this), space name is resolved with net_box schema. Since, after resolving #44, non-default vshard routers and Cartridge vshard groups are supported, to resolve the name we must know what vshard router should be used. Since using space id for crud.len is deprecated now, we won't support name resolve for operations with custom router statistics. Instead of this, a warning will be logged. crud.len statistics will be signed by space name or space id casted to string depending on is there a default router with space schema or not.

Follows up #44, part of #255

I didn't forget about

  • Tests
  • Changelog
  • Documentation

@DifferentialOrange DifferentialOrange force-pushed the DifferentialOrange/gh-44-vshard-groups branch 4 times, most recently from 522aeda to 9de1913 Compare August 16, 2022 14:51
@DifferentialOrange
Copy link
Member Author

Needs to be in sync with #317 since something may change with this patch

@DifferentialOrange DifferentialOrange changed the title support vshard groups api: support vshard groups Aug 16, 2022
@DifferentialOrange DifferentialOrange force-pushed the DifferentialOrange/gh-44-vshard-groups branch from 9de1913 to ccd69f9 Compare August 16, 2022 15:22
@oleg-jukovec oleg-jukovec self-requested a review August 17, 2022 05:47
@DifferentialOrange DifferentialOrange force-pushed the DifferentialOrange/gh-44-vshard-groups branch 2 times, most recently from 8a9876b to 8677a5e Compare August 17, 2022 13:21
@DifferentialOrange
Copy link
Member Author

DifferentialOrange commented Aug 18, 2022

Current implementation may be a bit difficult to review, I'll try to separate the implementation to several commits.

UPD: done.

@DifferentialOrange DifferentialOrange force-pushed the DifferentialOrange/gh-44-vshard-groups branch from 8677a5e to 679b582 Compare August 19, 2022 06:53
README.md Show resolved Hide resolved
crud/borders.lua Show resolved Hide resolved
crud/borders.lua Show resolved Hide resolved
crud/common/map_call_cases/base_iter.lua Outdated Show resolved Hide resolved
crud/common/schema.lua Show resolved Hide resolved
crud/common/sharding/sharding_func.lua Outdated Show resolved Hide resolved
crud/common/utils.lua Outdated Show resolved Hide resolved
crud/common/utils.lua Outdated Show resolved Hide resolved
Comment on lines +254 to +259
local vshard_router = vshard.router.static

if vshard_router == nil then
log.warn('Failed to resolve space name for stats: default vshard router not found')
return nil
end
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we add a vshard_router option for stats.wrap?

Copy link
Member Author

Choose a reason for hiding this comment

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

Since this case is related only to crud.len, we can make specific wrappers for it. But this behavior is deprecated and will be removed, so I decided not to make statistics code more complicated since it will become irrelevant after a couple of releases.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nothing is more permanent than a temporary solution.

The inconsistency of the code is not good, but you know more about the plans for the development of this product. So it's up to you.

test/integration/vshard_custom_test.lua Show resolved Hide resolved
@DifferentialOrange DifferentialOrange force-pushed the DifferentialOrange/gh-44-vshard-groups branch from 679b582 to 04bd845 Compare August 26, 2022 12:40
@DifferentialOrange DifferentialOrange force-pushed the DifferentialOrange/gh-44-vshard-groups branch 6 times, most recently from b332869 to fa69e83 Compare August 29, 2022 15:11
After discussion with Ecosystem team, we decided not to specify PR in
CHANGELOG entries if there is a related issue. This patch make last
CHANGELOG entries consistent.
@DifferentialOrange DifferentialOrange force-pushed the DifferentialOrange/gh-44-vshard-groups branch from fa69e83 to c3ffcb0 Compare August 29, 2022 15:54
This patch is the groundwork for vshard groups and custom routers
support.

Test runs have shown that this patch do not affects the performance of
crud requests.

Part of #44
This patch is the groundwork for vshard groups and custom routers
support.

After this patch, schema reload works per vshard router object.

Test runs have shown that this patch do not affects the performance of
crud requests.

Part of #44
This patch is the groundwork for vshard groups and custom routers
support.

After this patch, sharding schema reload works per vshard router object.

Test runs have shown that this patch do not affects the performance of
crud requests.

Part of #44
This patch is the groundwork for vshard groups and custom routers
support.

After this patch, vshard router object is retrieved only in the single
point of a request. (Except for name resolving in statistics.)

Test runs have shown that this patch do not affects the performance of
crud requests.

Part of #44
This patch adds Cartridge vshard groups [1] and non-default vshard
router [2] support to CRUD operations.

To specify Cartridge vshard group, pass vshard group name with
`vshard_router` option of a crud operation.
```lua
crud.select('customers_ddl',
            {{'=', 'age', 41}},
            {vshard_router = 'customers'})
```

To use non-default vshard router, pass vshard router object with
`vshard_router` option of a crud operation.
```lua
local router = vshard.router.new(cfg)

crud.select('customers_ddl',
            {{'=', 'age', 41}},
            {vshard_router = router})
```

If `vshard_router` is not specified, default vshard router is used to
process the request. If default vshard router is not found (for example,
if it is a Cartridge application with vshard groups) and option is not
specified, the error is returned.

1. https://www.tarantool.io/en/doc/latest/book/cartridge/cartridge_dev/#using-multiple-vshard-storage-groups
2. https://www.tarantool.io/ru/doc/latest/reference/reference_rock/vshard/vshard_router/#router-api-new

Closes #44
CRUD stats are separated by space name. If space id is passed instead of
name (only `crud.len` allows this), space name is resolved with net_box
schema. Since, after resolving #44, non-default vshard routers and
Cartridge vshard groups are supported, to resolve the name we must know
what vshard router should be used. Since using space id for `crud.len`
is deprecated now, we won't support name resolve for operations with
custom router statistics. Instead of this, a warning will be logged.
`crud.len` statistics will be signed by space name or space id casted to
string depending on is there a default router with space schema or not.

Follows up #44, part of #255
Copy link
Contributor

@oleg-jukovec oleg-jukovec left a comment

Choose a reason for hiding this comment

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

Thank you for the pull request!

@DifferentialOrange DifferentialOrange merged commit d6f7666 into master Aug 31, 2022
@DifferentialOrange DifferentialOrange deleted the DifferentialOrange/gh-44-vshard-groups branch August 31, 2022 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add shard group support
2 participants