Repository navigation
EXT-2683 Add ReassignTablets to CLI and CPP SDK - #59337
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the SDK and CLI tablet reassignment changes.
No open issues 🎉
What changed in this PR
Adds bulk tablet channel reassignment to the draft C++ SDK and administrative CLI, integrating with existing operation tracking and cancellation.
Changes:
- Adds
TTabletClient::ReassignTablets()and a typed operation exposing reassignment progress. - Adds
ydb admin database reassign-tablets, option validation, and pretty/JSON output, plus typed support inoperation get. - Adds mock-service tests covering requests, progress, cancellation, and errors, and updates changelogs.
| File | Description |
|---|---|
ydb/public/sdk/cpp/src/client/draft/ydb_tablet.cpp |
Implements reassignment requests and progress metadata extraction. |
ydb/public/sdk/cpp/src/client/draft/ya.make |
Registers the new SDK implementation. |
ydb/public/sdk/cpp/include/ydb-cpp-sdk/client/draft/ydb_tablet.h |
Declares client settings, operation metadata, and API. |
ydb/public/sdk/cpp/CHANGELOG.md |
Documents the new draft SDK API. |
ydb/public/lib/ydb_cli/common/print_operation.h |
Declares reassignment operation printing. |
ydb/public/lib/ydb_cli/common/print_operation.cpp |
Adds progress columns and output support. |
ydb/public/lib/ydb_cli/commands/ydb_service_operation.cpp |
Routes reassignment IDs to typed operation retrieval. |
ydb/public/lib/ydb_cli/commands/ydb_admin.h |
Declares the reassignment command and options. |
ydb/public/lib/ydb_cli/commands/ydb_admin.cpp |
Registers and implements the command with validation. |
ydb/apps/ydb/ut/reassign_tablets.cpp |
Tests SDK and CLI reassignment behavior using mock services. |
ydb/apps/ydb/ut/auth/ya.make |
Registers tests and the draft SDK dependency. |
ydb/apps/ydb/CHANGELOG.md |
Documents the CLI command and operation controls. |
Review effort: Balanced
|
⚪ ⚪
🟢
*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! 🚀 New features to boost your workflow:
|
| AddCommand(std::make_unique<TCommandDatabaseDump>()); | ||
| AddCommand(std::make_unique<TCommandDatabaseRestore>()); | ||
| AddCommand(std::make_unique<TCommandDatabaseAttribute>()); | ||
| AddCommand(std::make_unique<TCommandDatabaseReassignTablets>()); |
There was a problem hiding this comment.
[ИИ-ревью] Размещение в admin database подразумевает ограничение указанной БД, но на сервере -d только выбирает Hive, после чего фильтры применяются ко всем его таблеткам. Если несколько БД обслуживаются одним Hive, вызов с -d A --storage-pool pool_B может затронуть БД B; справка CLI об этом не предупреждает.
Для текущего поведения команду лучше разместить в существующем разделе кластерного администрирования: ydb admin cluster reassign-tablets. Обязательный -d можно сохранить для выбора Hive, явно пояснив в справке, что он не ограничивает выборку таблетками этой БД. Например:
Reassign tablet channels in the Hive serving the specified database. The database selects the Hive and does not restrict affected tablets to that database. Returns an operation ID; use
operation getto check progress andoperation cancelto stop scheduling.
Если команда остаётся в admin database, выборку следует ограничить указанной БД.
| .RequiredArgument("N").DefaultValue(1).StoreResult(&MaxInFlight); | ||
| config.Opts->AddLongOption("percent", "Percentage of matching tablets to reassign, starting with the oldest channel assignments.") | ||
| .RequiredArgument("N").DefaultValue(100).StoreResult(&Percent); | ||
| config.Opts->AddLongOption("async", "Mark channels for reassignment on a subsequent tablet restart.") |
There was a problem hiding this comment.
[ИИ-ревью] Флаг --async лучше назвать --on-restart: команда всегда возвращает operation без ожидания завершения, а этот флаг управляет другим поведением — откладывает переназначение каналов до последующего рестарта таблетки. Название --async легко принять за переключатель ожидания; --on-restart передаёт фактический смысл.
| config.SetFreeArgsNum(0); | ||
| config.Opts->AddLongOption("storage-pool", "Filter by storage pool name. Specify this or a nonzero --group, or both.") | ||
| .RequiredArgument("NAME").StoreResult(&StoragePool); | ||
| config.Opts->AddLongOption("group", "Filter by group ID. Not specifying selects all groups in --storage-pool.") |
There was a problem hiding this comment.
[ИИ-ревью] Здесь лучше использовать --group-id: суффикс -id соответствует существующим в CLI --node-id и --partition-id. В справке также стоит уточнить, что это исходная, текущая storage group, а не целевая группа переназначения. Например: Filter channels by their current storage group ID. If omitted, select all groups in --storage-pool.
|
⚪ ⚪
🟢
*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation |
| case TOperationId::SET_NOT_NULL: | ||
| return GetOperation<NTable::TSetNotNullOperation>(client, OperationId, OutputFormat); | ||
| case TOperationId::REASSIGN_TABLETS: | ||
| return GetOperation<NTablet::TReassignTabletsOperation>(client, OperationId, OutputFormat); |
There was a problem hiding this comment.
[ИИ-ревью] После отмены ещё идущей операции GetOperation возвращает CANCELLED вместе с числом выбранных и обработанных таблеток. Здесь ThrowOnError вызывается до PrintOperation, поэтому ydb operation get не показывает эти счётчики ни в таблице, ни в JSON. Для отменённой операции стоит выводить её статус и счётчики, сохранив ненулевой код выхода. Сценарий cancel → get стоит покрыть тестом: текущий тест проверяет только отправку отмены.
| .RequiredArgument("N").DefaultValue(1).StoreResult(&MaxInFlight); | ||
| config.Opts->AddLongOption("percent", "Percentage of matching tablets to reassign, starting with the oldest channel assignments.") | ||
| .RequiredArgument("N").DefaultValue(100).StoreResult(&Percent); | ||
| config.Opts->AddLongOption("on-restart", "Mark channels for reassignment on a subsequent tablet restart.") |
There was a problem hiding this comment.
[ИИ-ревью] При --on-restart Hive засчитывает таблетку сразу после того, как помечает её каналы для переназначения. Поэтому ready=true и completed tablets == selected tablets возможны ещё до первого рестарта. Стоит явно указать в справке --on-restart и в описании TReassignTabletsOperation::TMetadata::CompletedTablets в SDK, что в этом режиме прогресс показывает число помеченных таблеток, а фактическое переназначение произойдёт при их последующих рестартах.
| .Column(3, metadata.SelectedTablets) | ||
| .Column(4, metadata.CompletedTablets); |
There was a problem hiding this comment.
[ИИ-ревью] Если срок хранения операции истёк, operation get получает NOT_FOUND и ID из запроса, но без метаданных. После переноса печати перед проверкой статуса таблица показывает 0 выбранных и 0 обработанных таблеток, хотя фактические значения неизвестны. JSON в этом случае уже опускает метаданные. Когда метаданных нет, в таблице лучше оставить обе ячейки пустыми или вывести —, сохранив 0 для счётчиков, которые сервер действительно вернул.
|
⚪ ⚪
🟢
*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation |
|
Про CLI-часть. Сейчас параллельно идёт большая задача с переездом команд |
ab654c3 to
53a65b8
Compare
|
⚪ ⚪
🟢
*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation |
|
⚪ ⚪
🟢
*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation |
|
⚪ ⚪
🟢
*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation |
Changelog entry
Add ReassignTablets command to CLI and CPP SDK
Description for reviewers
...