Skip to content

EXT-2683 Add ReassignTablets to CLI and CPP SDK - #59337

Merged
alexv-smirnov merged 11 commits into
ydb-platform:mainfrom
SammyVimes:ext-2683
Nov 18, 2026
Merged

alexv-smirnov merged 11 commits into
ydb-platform:mainfrom
SammyVimes:ext-2683

Conversation

@SammyVimes

Copy link
Copy Markdown
Contributor

Changelog entry

Add ReassignTablets command to CLI and CPP SDK

Description for reviewers

...

@SammyVimes
SammyVimes requested review from a team as code owners November 13, 2026 12:53
Copilot AI balanced review requested due to automatic review settings November 13, 2026 12:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 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 in operation 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

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

⚪ 2026-11-13 13:16:26 UTC Pre-commit check linux-x86_64-relwithdebinfo for a5d5092 has started.
⚪ 2026-11-13 13:17:28 UTC Artifacts will be uploaded here
⚪ 2026-11-13 13:18:55 UTC ya make is running...
🟡 2026-11-13 14:47:45 UTC Some tests failed, follow the links below. Going to retry failed tests...

Details

Ya make output

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
58398 56549 0 8 1835 6

⚪ 2026-11-13 14:48:04 UTC ya make is running... (failed tests rerun, try 2)
🟢 2026-11-13 14:55:28 UTC Tests successful.

Ya make output

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
122 (only retried tests) 121 0 0 0 1

🟢 2026-11-13 14:55:32 UTC Build successful.
🟡 2026-11-13 14:56:08 UTC ydbd size 2.8 GiB changed* by +12.8 MiB, which is >= 100.0 KiB vs main: Warning

ydbd size dash main: 7c1bcec merge: a5d5092 diff diff %
ydbd size 3 045 473 272 Bytes 3 058 881 272 Bytes +12.8 MiB +0.440%
ydbd stripped size 643 672 192 Bytes 644 927 840 Bytes +1.2 MiB +0.195%

*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation

dcherednik
dcherednik previously approved these changes Nov 13, 2026
@codecov-commenter

codecov-commenter commented Nov 13, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.38462% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
ydb/public/lib/ydb_cli/common/print_operation.cpp 91.30% 0 Missing and 2 partials ⚠️
...lic/lib/ydb_cli/commands/ydb_service_operation.cpp 75.00% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

AddCommand(std::make_unique<TCommandDatabaseDump>());
AddCommand(std::make_unique<TCommandDatabaseRestore>());
AddCommand(std::make_unique<TCommandDatabaseAttribute>());
AddCommand(std::make_unique<TCommandDatabaseReassignTablets>());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[ИИ-ревью] Размещение в 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 get to check progress and operation cancel to 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.")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[ИИ-ревью] Флаг --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.")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[ИИ-ревью] Здесь лучше использовать --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.

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

⚪ 2026-11-13 19:56:32 UTC Pre-commit check linux-x86_64-relwithdebinfo for e0fa73d has started.
⚪ 2026-11-13 19:57:03 UTC Artifacts will be uploaded here
⚪ 2026-11-13 19:58:30 UTC ya make is running...
🟡 2026-11-13 21:15:29 UTC Some tests failed, follow the links below. Going to retry failed tests...

Details

Ya make output

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
56140 54330 0 8 1795 7

⚪ 2026-11-13 21:15:49 UTC ya make is running... (failed tests rerun, try 2)
🟢 2026-11-13 21:23:02 UTC Tests successful.

Ya make output

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
102 (only retried tests) 101 0 0 0 1

🟢 2026-11-13 21:23:07 UTC Build successful.
🟡 2026-11-13 21:23:33 UTC ydbd size 2.9 GiB changed* by +16.1 MiB, which is >= 100.0 KiB vs main: Warning

ydbd size dash main: 7c1bcec merge: e0fa73d diff diff %
ydbd size 3 045 473 272 Bytes 3 062 355 504 Bytes +16.1 MiB +0.554%
ydbd stripped size 643 672 192 Bytes 645 490 176 Bytes +1.7 MiB +0.282%

*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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[ИИ-ревью] После отмены ещё идущей операции 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.")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[ИИ-ревью] При --on-restart Hive засчитывает таблетку сразу после того, как помечает её каналы для переназначения. Поэтому ready=true и completed tablets == selected tablets возможны ещё до первого рестарта. Стоит явно указать в справке --on-restart и в описании TReassignTabletsOperation::TMetadata::CompletedTablets в SDK, что в этом режиме прогресс показывает число помеченных таблеток, а фактическое переназначение произойдёт при их последующих рестартах.

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

⚪ 2026-11-16 11:15:38 UTC Pre-commit check linux-x86_64-relwithdebinfo for 8850a86 has started.
⚪ 2026-11-16 11:17:03 UTC Artifacts will be uploaded here
⚪ 2026-11-16 11:18:35 UTC ya make is running...
⚫ 2026-11-16 11:58:49 UTC Check cancelled

Comment on lines +514 to +515
.Column(3, metadata.SelectedTablets)
.Column(4, metadata.CompletedTablets);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[ИИ-ревью] Если срок хранения операции истёк, operation get получает NOT_FOUND и ID из запроса, но без метаданных. После переноса печати перед проверкой статуса таблица показывает 0 выбранных и 0 обработанных таблеток, хотя фактические значения неизвестны. JSON в этом случае уже опускает метаданные. Когда метаданных нет, в таблице лучше оставить обе ячейки пустыми или вывести —, сохранив 0 для счётчиков, которые сервер действительно вернул.

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

⚪ 2026-11-16 12:42:48 UTC Pre-commit check linux-x86_64-relwithdebinfo for b87264a has started.
⚪ 2026-11-16 12:43:26 UTC Artifacts will be uploaded here
⚪ 2026-11-16 12:44:52 UTC ya make is running...
🟡 2026-11-16 14:21:11 UTC Some tests failed, follow the links below. Going to retry failed tests...

Details

Ya make output

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
57438 55633 0 7 1791 7

⚪ 2026-11-16 14:21:28 UTC ya make is running... (failed tests rerun, try 2)
🟢 2026-11-16 14:28:43 UTC Tests successful.

Ya make output

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
177 (only retried tests) 176 0 0 0 1

🟢 2026-11-16 14:28:48 UTC Build successful.
🟡 2026-11-16 14:29:11 UTC ydbd size 2.9 GiB changed* by +16.9 MiB, which is >= 100.0 KiB vs main: Warning

ydbd size dash main: 7c1bcec merge: b87264a diff diff %
ydbd size 3 045 473 272 Bytes 3 063 184 928 Bytes +16.9 MiB +0.582%
ydbd stripped size 643 672 192 Bytes 645 605 504 Bytes +1.8 MiB +0.300%

*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation

pnv1
pnv1 previously approved these changes Nov 16, 2026

@pnv1 pnv1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

CLI part LGTM

Comment thread ydb/public/sdk/cpp/CHANGELOG.md Resolved
@pnv1

pnv1 commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Про CLI-часть. Сейчас параллельно идёт большая задача с переездом команд ydbd в ydb. И там много команд с таблетками. Кажется, намечается дерево команд ydb admin tablet. Я бы пока попросил по возможности подождать с добавлением этой команды, пока не определимся с новым деревом команд

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

⚪ 2026-11-18 07:30:23 UTC Pre-commit check linux-x86_64-relwithdebinfo for 0f5bc61 has started.
⚪ 2026-11-18 07:30:44 UTC Artifacts will be uploaded here
⚪ 2026-11-18 07:32:13 UTC ya make is running...
⚫ 2026-11-18 08:18:11 UTC Check cancelled

@SammyVimes
SammyVimes requested review from Shfdis and pnv1 November 18, 2026 08:20
@SammyVimes
SammyVimes force-pushed the ext-2683 branch 2 times, most recently from ab654c3 to 53a65b8 Compare November 18, 2026 08:30
Comment thread ydb/apps/ydb/CHANGELOG.md Resolved
@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

⚪ 2026-11-18 09:07:22 UTC Pre-commit check linux-x86_64-relwithdebinfo for 061facc has started.
⚪ 2026-11-18 09:07:44 UTC Artifacts will be uploaded here
⚪ 2026-11-18 09:09:21 UTC ya make is running...
⚫ 2026-11-18 09:09:47 UTC Check cancelled

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

⚪ 2026-11-18 09:23:28 UTC Pre-commit check linux-x86_64-relwithdebinfo for 18c1e5c has started.
⚪ 2026-11-18 09:23:49 UTC Artifacts will be uploaded here
⚪ 2026-11-18 09:25:18 UTC ya make is running...
🟡 2026-11-18 10:42:00 UTC Some tests failed, follow the links below. Going to retry failed tests...

Details

Ya make output

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
57715 55914 0 2 1793 6

⚪ 2026-11-18 10:42:17 UTC ya make is running... (failed tests rerun, try 2)
🟢 2026-11-18 10:43:25 UTC Tests successful.

Ya make output

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
14 (only retried tests) 13 0 0 0 1

🟢 2026-11-18 10:43:29 UTC Build successful.
🟡 2026-11-18 10:43:54 UTC ydbd size 2.9 GiB changed* by +27.1 MiB, which is >= 100.0 KiB vs main: Warning

ydbd size dash main: 7c1bcec merge: 18c1e5c diff diff %
ydbd size 3 045 473 272 Bytes 3 073 880 792 Bytes +27.1 MiB +0.933%
ydbd stripped size 643 672 192 Bytes 646 959 040 Bytes +3.1 MiB +0.511%

*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation

pnv1
pnv1 previously approved these changes Nov 18, 2026
Shfdis
Shfdis previously approved these changes Nov 18, 2026
@SammyVimes
SammyVimes dismissed stale reviews from Shfdis and pnv1 via 2c67e78 November 18, 2026 12:28
@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

⚪ 2026-11-18 12:30:57 UTC Pre-commit check linux-x86_64-relwithdebinfo for a05ec94 has started.
⚪ 2026-11-18 12:31:19 UTC Artifacts will be uploaded here
⚪ 2026-11-18 12:32:48 UTC ya make is running...
🟡 2026-11-18 14:02:41 UTC Some tests failed, follow the links below. Going to retry failed tests...

Details

Ya make output

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
57770 55964 0 6 1793 7

⚪ 2026-11-18 14:02:59 UTC ya make is running... (failed tests rerun, try 2)
🟢 2026-11-18 14:10:26 UTC Tests successful.

Ya make output

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
106 (only retried tests) 105 0 0 0 1

🟢 2026-11-18 14:10:31 UTC Build successful.
🟡 2026-11-18 14:10:55 UTC ydbd size 2.9 GiB changed* by +27.5 MiB, which is >= 100.0 KiB vs main: Warning

ydbd size dash main: 7c1bcec merge: a05ec94 diff diff %
ydbd size 3 045 473 272 Bytes 3 074 337 776 Bytes +27.5 MiB +0.948%
ydbd stripped size 643 672 192 Bytes 647 015 872 Bytes +3.2 MiB +0.519%

*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

⚪ 2026-11-18 14:45:22 UTC Pre-commit check linux-x86_64-relwithdebinfo for c4e0edc has started.
⚪ 2026-11-18 14:45:48 UTC Artifacts will be uploaded here
⚪ 2026-11-18 14:47:16 UTC ya make is running...
🟡 2026-11-18 16:41:39 UTC Some tests failed, follow the links below. Going to retry failed tests...

Details

Ya make output

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
57831 56028 0 1 1793 9

⚪ 2026-11-18 16:41:57 UTC ya make is running... (failed tests rerun, try 2)
🟢 2026-11-18 16:43:10 UTC Tests successful.

Ya make output

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
12 (only retried tests) 11 0 0 0 1

🟢 2026-11-18 16:43:15 UTC Build successful.
🟡 2026-11-18 16:43:38 UTC ydbd size 2.9 GiB changed* by +29.9 MiB, which is >= 100.0 KiB vs main: Warning

ydbd size dash main: 7c1bcec merge: c4e0edc diff diff %
ydbd size 3 045 473 272 Bytes 3 076 800 032 Bytes +29.9 MiB +1.029%
ydbd stripped size 643 672 192 Bytes 647 242 688 Bytes +3.4 MiB +0.555%

*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation

@alexv-smirnov
alexv-smirnov merged commit 074e653 into ydb-platform:main Nov 18, 2026
12 of 14 checks passed
@ydbot

ydbot commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

Backport

To backport this PR, click the button next to the target branch and then click "Run workflow" in the Run Actions UI.

Branch Run
stable-26-3-1, stable-26-4-1 ▶  Backport
stable-26-4-1 ▶  Backport

▶  Backport manual

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.

8 participants