Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 25, 2025

Changelog entry

Added --tx-mode option to ydb sql command with support for all transaction modes including snapshot isolation (snapshot-ro, snapshot-rw). Also added snapshot isolation modes to ydb table query execute.

Changelog category

  • New feature

Description for reviewers

Adds --tx-mode support to ydb sql command (previously only available in ydb table query execute) and extends both commands with snapshot isolation modes.

Supported modes:

  • serializable-rw
  • online-ro
  • stale-ro
  • snapshot-ro — new snapshot read-only isolation
  • snapshot-rw — new snapshot read-write isolation
  • no-tx — no transaction (default for ydb sql, also accepts notx for backward compatibility)

Changes:

  • ydb_sql.h/cpp: Added --tx-mode option with default no-tx and transaction control logic
  • ydb_service_table.cpp: Added snapshot-ro/snapshot-rw to ExecuteDataQuery, StreamExecuteQuery, and help text
  • ydb/apps/ydb/CHANGELOG.md: Added changelog entry

Usage:

ydb sql --tx-mode snapshot-ro -s "SELECT * FROM my_table"
ydb table query execute --tx-mode snapshot-rw -t generic -q "SELECT * FROM my_table"
Original prompt

This section details on the original issue you should resolve

<issue_title>Support snapshot isolation mode in ydb cli</issue_title>
<issue_description>API:

message SnapshotRWModeSettings {

message SnapshotRWModeSettings {

C++ SDK already supports this mode

Need to support --tx-mode option (with all supported tx modes, includes snapshot isolation mode) in ydb sql command (like ydb table query execute):

ydb table query execute --help
Usage: ydb [global options...] table query execute [options...]

Description: Execute query

Global options:
  {-e|--endpoint}, {-d|--database}, {-v|--verbose}, {-p|--profile}, {-y|--assume-yes}, --ca-file, --client-cert-file, --client-cert-key-file, --client-cert-key-password-file, --iam-token-file, --yc-token-file, --use-metadata-credentials, --sa-key-file, --token-file, --user, --password-file, --no-password, --oauth2-key-file, --iam-endpoint, --profile-file
  To get full description of these options run 'ydb --help'.

Options:
  {-h|--help}            Print usage, -hh for detailed help
  --timeout ms           Operation timeout. Operation should be executed on server within this timeout. There could also be a delay up to 200ms to receive timeout error from server.
  --help-ex              Print usage with examples
  {-t|--type} [String]   Query type [data, scheme, scan, generic] (default: data)
  --stats [String]       Collect statistics mode (for data & scan & generic queries) [none, basic, full]
  --flame-graph PATH     Builds resource usage flame graph, based on statistics info
  -s                     Collect statistics in basic mode
  --tx-mode [String]     Transaction mode (for generic & data queries) [serializable-rw, online-ro, stale-ro, notx (generic queries only)] (default: serializable-rw)
...

</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@github-actions
Copy link

Hi! Thank you for contributing!
The tests on this PR will run after a maintainer adds an ok-to-test label to this PR manually. Thank you for your patience!

@github-actions
Copy link

github-actions bot commented Nov 25, 2025

🟢 2025-11-25 16:04:37 UTC The validation of the Pull Request description is successful.

@asmyasnikov asmyasnikov changed the title [WIP] Add support for snapshot isolation mode in ydb cli [WIP] Add support for snapshot-rw isolation mode in ydb cli Nov 25, 2025
@asmyasnikov asmyasnikov added the ok-to-test Special label used to approve a PR for testing on our infrastructure label Nov 25, 2025
@github-actions github-actions bot removed the ok-to-test Special label used to approve a PR for testing on our infrastructure label Nov 25, 2025
@github-actions
Copy link

github-actions bot commented Nov 25, 2025

2025-11-25 14:53:48 UTC Pre-commit check linux-x86_64-relwithdebinfo for b4c48e6 has started.
2025-11-25 14:54:06 UTC Artifacts will be uploaded here
2025-11-25 14:56:15 UTC ya make is running...
🟢 2025-11-25 14:56:21 UTC Tests successful.

Ya make output | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
0 0 0 0 0 0

🟢 2025-11-25 14:56:27 UTC Build successful.

@github-actions
Copy link

github-actions bot commented Nov 25, 2025

2025-11-25 14:54:14 UTC Pre-commit check linux-x86_64-release-asan for b4c48e6 has started.
2025-11-25 14:54:32 UTC Artifacts will be uploaded here
2025-11-25 14:56:39 UTC ya make is running...
🟢 2025-11-25 14:56:45 UTC Tests successful.

Ya make output | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
0 0 0 0 0 0

🟢 2025-11-25 14:56:50 UTC Build successful.

…ecute commands

Co-authored-by: asmyasnikov <14202262+asmyasnikov@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for snapshot-rw isolation mode in ydb cli Support snapshot isolation mode in ydb cli Nov 25, 2025
Copilot AI requested a review from asmyasnikov November 25, 2025 15:17
Copilot finished work on behalf of asmyasnikov November 25, 2025 15:17
@pnv1
Copy link
Collaborator

pnv1 commented Nov 25, 2025

@copilot

  • First, lets use "no-tx" in command option description. But support bot "no-tx" and "notx" options. For both ydb table query execute and ydb sql command.
  • Second, add a changelog entry please to YDB CLI changelog file https://github.com/ydb-platform/ydb/blob/main/ydb/apps/ydb/CHANGELOG.md based on other entries. But do not add too much details. Something like "The X option was added to the Y command"

…x' and 'notx', add changelog entry

Co-authored-by: pnv1 <2571062+pnv1@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 25, 2025

@copilot

  • First, lets use "no-tx" in command option description. But support bot "no-tx" and "notx" options. For both ydb table query execute and ydb sql command.
  • Second, add a changelog ent...

Addressed in 524f543. Changed help text to use no-tx, set default for ydb sql to no-tx, and added support for both no-tx and notx in both commands. Also added changelog entry.

Copilot AI requested a review from pnv1 November 25, 2025 15:53
Copilot finished work on behalf of pnv1 November 25, 2025 15:53
@asmyasnikov asmyasnikov marked this pull request as ready for review November 25, 2025 16:00
@asmyasnikov asmyasnikov requested a review from a team as a code owner November 25, 2025 16:00
Copilot AI review requested due to automatic review settings November 25, 2025 16:00
@asmyasnikov asmyasnikov added the ok-to-test Special label used to approve a PR for testing on our infrastructure label Nov 25, 2025
@github-actions github-actions bot removed the ok-to-test Special label used to approve a PR for testing on our infrastructure label Nov 25, 2025
@asmyasnikov asmyasnikov enabled auto-merge (squash) November 25, 2025 16:01
@github-actions
Copy link

github-actions bot commented Nov 25, 2025

2025-11-25 16:02:15 UTC Pre-commit check linux-x86_64-relwithdebinfo for 0a9eea4 has started.
2025-11-25 16:02:33 UTC Artifacts will be uploaded here
2025-11-25 16:04:46 UTC ya make is running...
🟡 2025-11-25 16:36:22 UTC Some tests failed, follow the links below. Going to retry failed tests...

Ya make output | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
2266 2251 0 1 7 7

2025-11-25 16:36:30 UTC ya make is running... (failed tests rerun, try 2)
🟢 2025-11-25 16:51:00 UTC Tests successful.

Ya make output | Test bloat | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
13 (only retried tests) 11 0 0 0 2

🟢 2025-11-25 16:51:07 UTC Build successful.
🟢 2025-11-25 16:51:25 UTC ydbd size 2.3 GiB changed* by 0 Bytes, which is <= 0 Bytes vs main: OK

ydbd size dash main: 4567cc7 merge: 0a9eea4 diff diff %
ydbd size 2 455 679 936 Bytes 2 455 679 936 Bytes 0 Bytes 0.000%
ydbd stripped size 523 368 856 Bytes 523 368 856 Bytes 0 Bytes 0.000%

*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
Copy link

github-actions bot commented Nov 25, 2025

2025-11-25 16:03:19 UTC Pre-commit check linux-x86_64-release-asan for 0a9eea4 has started.
2025-11-25 16:03:29 UTC Artifacts will be uploaded here
2025-11-25 16:04:44 UTC ya make is running...
🟢 2025-11-25 16:17:59 UTC Tests successful.

Ya make output | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
335 335 0 0 0 0

🟢 2025-11-25 16:18:05 UTC Build successful.
🟢 2025-11-25 16:18:24 UTC ydbd size 3.8 GiB changed* by -96 Bytes, which is <= 0 Bytes vs main: OK

ydbd size dash main: 4567cc7 merge: 0a9eea4 diff diff %
ydbd size 4 110 828 128 Bytes 4 110 828 032 Bytes -96 Bytes -0.000%
ydbd stripped size 1 528 019 056 Bytes 1 528 018 992 Bytes -64 Bytes -0.000%

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

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds support for snapshot isolation transaction modes (snapshot-ro and snapshot-rw) to the YDB CLI commands. It extends the --tx-mode option to the ydb sql command (previously only available in ydb table query execute) and adds the new snapshot isolation modes to both commands.

  • Added --tx-mode option to ydb sql command with default value no-tx
  • Extended both ydb sql and ydb table query execute commands with snapshot-ro and snapshot-rw transaction modes
  • Maintained backward compatibility by supporting both no-tx and notx (deprecated) values

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
ydb/public/lib/ydb_cli/commands/ydb_sql.h Added TxMode field to store transaction mode configuration
ydb/public/lib/ydb_cli/commands/ydb_sql.cpp Implemented --tx-mode option with transaction control logic supporting all modes including snapshot isolation
ydb/public/lib/ydb_cli/commands/ydb_service_table.cpp Added snapshot isolation modes to both data and generic query execution, updated help text
ydb/apps/ydb/CHANGELOG.md Documented the new features in the changelog

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

} else if (TxMode == "snapshot-ro") {
txSettings = NTable::TTxSettings::SnapshotRO();
} else if (TxMode == "snapshot-rw") {
txSettings = NTable::TTxSettings::SnapshotRW();
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

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

The ExecuteDataQuery function doesn't handle "no-tx" or "notx" transaction modes, even though the help text at line 370 mentions "no-tx (generic queries only)". While this is consistent with the help text's indication that no-tx is only for generic queries, the function should still validate that the user hasn't provided these invalid modes for data queries. Consider adding a check:

} else if (TxMode == "no-tx" || TxMode == "notx") {
    throw TMisuseException() << "Transaction mode 'no-tx' is only supported for generic queries.";

This would provide a more helpful error message than "Unknown transaction mode."

Suggested change
txSettings = NTable::TTxSettings::SnapshotRW();
txSettings = NTable::TTxSettings::SnapshotRW();
} else if (TxMode == "no-tx" || TxMode == "notx") {
throw TMisuseException() << "Transaction mode 'no-tx' is only supported for generic queries.";

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

Choose a reason for hiding this comment

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

ExecuteDataQuery does not support NoTx tx-control

Copy link
Member

Choose a reason for hiding this comment

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

no-tx не должно быть в ydb table query execute

@asmyasnikov asmyasnikov merged commit a62dc1e into main Nov 25, 2025
20 of 22 checks passed
@Gazizonoki Gazizonoki deleted the copilot/support-snapshot-isolation branch November 25, 2025 18:28
@pnv1
Copy link
Collaborator

pnv1 commented Nov 27, 2025

Docs issue: #29605

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support snapshot-rw isolation mode in ydb cli

4 participants