Skip to content

datashard: add NULL value check to TValidatedWriteTxOperation::ParseOperation #21560

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

Merged
merged 2 commits into from
Jul 25, 2025

Conversation

ztlpn
Copy link
Collaborator

@ztlpn ztlpn commented Jul 23, 2025

Fixes #21475

Changelog entry

Changelog category

  • Not for changelog (changelog entry is not required)

Description for reviewers

@ztlpn ztlpn requested a review from a team as a code owner July 23, 2025 16:30
Copy link

github-actions bot commented Jul 23, 2025

2025-07-23 16:31:37 UTC Pre-commit check linux-x86_64-relwithdebinfo for 27f0f30 has started.
2025-07-23 16:31:51 UTC Artifacts will be uploaded here
2025-07-23 16:35:14 UTC ya make is running...
🟡 2025-07-23 17:44:53 UTC Some tests failed, follow the links below. Going to retry failed tests...

Test history | Ya make output | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
29909 28462 0 4 1410 33

2025-07-23 17:47:28 UTC ya make is running... (failed tests rerun, try 2)
🟢 2025-07-23 17:59:32 UTC Tests successful.

Test history | Ya make output | Test bloat | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
403 (only retried tests) 325 0 0 52 26

🟢 2025-07-23 17:59:40 UTC Build successful.
🟢 2025-07-23 18:00:01 UTC ydbd size 2.2 GiB changed* by +480 Bytes, which is < 100.0 KiB vs main: OK

ydbd size dash main: 9911a2e merge: 27f0f30 diff diff %
ydbd size 2 399 470 712 Bytes 2 399 471 192 Bytes +480 Bytes +0.000%
ydbd stripped size 501 723 016 Bytes 501 723 208 Bytes +192 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

@ztlpn ztlpn requested review from azevaykin and flown4qqqq July 23, 2025 16:31
Copy link

🟢 2025-07-23 16:33:20 UTC The validation of the Pull Request description is successful.

Copy link

github-actions bot commented Jul 23, 2025

2025-07-23 16:33:21 UTC Pre-commit check linux-x86_64-release-asan for 27f0f30 has started.
2025-07-23 16:33:25 UTC Artifacts will be uploaded here
2025-07-23 16:36:46 UTC ya make is running...
🟡 2025-07-23 18:26:54 UTC Some tests failed, follow the links below. This fail is not in blocking policy yet

Test history | Ya make output | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
14486 14114 0 89 265 18

🟢 2025-07-23 18:28:09 UTC Build successful.
🟢 2025-07-23 18:28:36 UTC ydbd size 3.9 GiB changed* by +2.0 KiB, which is < 100.0 KiB vs main: OK

ydbd size dash main: 9911a2e merge: 27f0f30 diff diff %
ydbd size 4 218 876 648 Bytes 4 218 878 664 Bytes +2.0 KiB +0.000%
ydbd stripped size 1 461 975 544 Bytes 1 461 976 248 Bytes +704 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

azevaykin
azevaykin previously approved these changes Jul 24, 2025

Cout << "========= Send immediate write with NULL value for NOT NULL column=========\n";
{
TSerializedCellMatrix matrix({TCell{}}, 1, 1);
Copy link
Member

@snaury snaury Jul 24, 2025

Choose a reason for hiding this comment

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

На всякий случай упомяну, что этого теста недостаточно. Если я правильно понял в этом тесте создаётся таблица с единственной ключевой колонкой, и по своей сути ключевая колонка должна обязательно быть указана. Интереснее случай, когда в таблице например 3 колонки (key, value1, value2 not null) и делают UPSERT с указанием (key, value1) - обе с not null значением, а колонку value2 не указывают. Из-за того, что на уровне локальной базы у неё нет дефолта туда вставится NULL. И здесь появляется интересная проблема, что если по ключу уже есть строка, то это не ошибка (т.к. это UPDATE), а если строки нет - то ошибка (т.к. это INSERT). То есть в таких случаях мы не можем проверить корректность операции на стадии валидации, из-за того что KQP нам UPDATE присылает как UPSERT, и это видимо можно проверить только во время выполнения. Однако если операция INSERT, или в списке колонок указали явный NULL, то проверить во время валидации можно.

Copy link
Member

Choose a reason for hiding this comment

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

На кофепоинте gvit@ сказал, что все эти contraint'ы всё-равно несовместимы с быстрым UPSERT, и будет нормально всегда читать если есть NOT NULL колонки, которые не указаны в операции. Мы с дефолтами вобщем-то уже так читаем, и с тех пор как у нас незакомиченные изменения и волатильные транзакции появились вынуждены читать для проверки конфликтов, так что особых проблем вроде бы нет.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Добавил проверку для INSERT и тесты.

Copy link

github-actions bot commented Jul 24, 2025

2025-07-24 17:33:14 UTC Pre-commit check linux-x86_64-release-asan for 966962a has started.
2025-07-24 17:33:28 UTC Artifacts will be uploaded here
2025-07-24 17:36:43 UTC ya make is running...
🟡 2025-07-24 19:23:18 UTC Some tests failed, follow the links below. This fail is not in blocking policy yet

Test history | Ya make output | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
14502 14115 0 102 265 20

🟢 2025-07-24 19:24:33 UTC Build successful.
🟢 2025-07-24 19:25:02 UTC ydbd size 3.9 GiB changed* by +10.5 KiB, which is < 100.0 KiB vs main: OK

ydbd size dash main: 336854d merge: 966962a diff diff %
ydbd size 4 219 444 208 Bytes 4 219 454 992 Bytes +10.5 KiB +0.000%
ydbd stripped size 1 462 230 744 Bytes 1 462 233 048 Bytes +2.2 KiB +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

github-actions bot commented Jul 24, 2025

2025-07-24 17:33:34 UTC Pre-commit check linux-x86_64-relwithdebinfo for 966962a has started.
2025-07-24 17:33:48 UTC Artifacts will be uploaded here
2025-07-24 17:37:08 UTC ya make is running...
🟡 2025-07-24 18:45:41 UTC Some tests failed, follow the links below. Going to retry failed tests...

Test history | Ya make output | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
29937 28502 0 1 1403 31

2025-07-24 18:48:22 UTC ya make is running... (failed tests rerun, try 2)
🟢 2025-07-24 19:00:22 UTC Tests successful.

Test history | Ya make output | Test bloat | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
267 (only retried tests) 195 0 0 49 23

🟢 2025-07-24 19:00:30 UTC Build successful.
🟢 2025-07-24 19:00:49 UTC ydbd size 2.2 GiB changed* by +5.6 KiB, which is < 100.0 KiB vs main: OK

ydbd size dash main: 336854d merge: 966962a diff diff %
ydbd size 2 399 781 488 Bytes 2 399 787 216 Bytes +5.6 KiB +0.000%
ydbd stripped size 501 806 344 Bytes 501 806 984 Bytes +640 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

github-actions bot commented Jul 25, 2025

2025-07-25 12:32:01 UTC Pre-commit check linux-x86_64-relwithdebinfo for 326ac70 has started.
2025-07-25 12:32:16 UTC Artifacts will be uploaded here
2025-07-25 12:35:39 UTC ya make is running...
🟡 2025-07-25 13:44:59 UTC Some tests failed, follow the links below. Going to retry failed tests...

Test history | Ya make output | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
29956 28517 0 4 1403 32

2025-07-25 13:47:37 UTC ya make is running... (failed tests rerun, try 2)
🟢 2025-07-25 14:00:36 UTC Tests successful.

Test history | Ya make output | Test bloat | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
391 (only retried tests) 318 0 0 49 24

🟢 2025-07-25 14:00:44 UTC Build successful.
🟢 2025-07-25 14:01:05 UTC ydbd size 2.2 GiB changed* by +5.5 KiB, which is < 100.0 KiB vs main: OK

ydbd size dash main: 40cb259 merge: 326ac70 diff diff %
ydbd size 2 403 016 840 Bytes 2 403 022 504 Bytes +5.5 KiB +0.000%
ydbd stripped size 502 188 232 Bytes 502 188 808 Bytes +576 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

github-actions bot commented Jul 25, 2025

2025-07-25 12:32:09 UTC Pre-commit check linux-x86_64-release-asan for 326ac70 has started.
2025-07-25 12:32:23 UTC Artifacts will be uploaded here
2025-07-25 12:35:39 UTC ya make is running...
🟡 2025-07-25 14:20:20 UTC Some tests failed, follow the links below. This fail is not in blocking policy yet

Test history | Ya make output | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
14521 14129 0 115 254 23

🟢 2025-07-25 14:21:37 UTC Build successful.
🟢 2025-07-25 14:22:05 UTC ydbd size 3.9 GiB changed* by +10.5 KiB, which is < 100.0 KiB vs main: OK

ydbd size dash main: 40cb259 merge: 326ac70 diff diff %
ydbd size 4 224 886 304 Bytes 4 224 897 072 Bytes +10.5 KiB +0.000%
ydbd stripped size 1 463 369 976 Bytes 1 463 372 280 Bytes +2.2 KiB +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

@ztlpn ztlpn merged commit 10951bf into ydb-platform:main Jul 25, 2025
13 checks passed
@ztlpn ztlpn deleted the gh-21475 branch July 25, 2025 14:44
PavelEfarinov pushed a commit to PavelEfarinov/ydb that referenced this pull request Aug 18, 2025
maVovk pushed a commit to maVovk/ydb that referenced this pull request Aug 19, 2025
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.

Reject to write NULL values into NOT NULL columns through Datashard
3 participants