Skip to content

Conversation

@ztlpn
Copy link
Collaborator

@ztlpn ztlpn commented Sep 9, 2025

Changelog entry

Fix a bug that could in rare cases lead to base statistics reported to the optimizer to go backwards in time or even to zero values.

Changelog category

  • Not for changelog

Description for reviewers

Don't publish base statistics updates from SchemeShard in StatisticsAggregator before the local tx is committed.

@github-actions github-actions bot added the bugfix label Sep 9, 2025
@ztlpn ztlpn self-assigned this Sep 9, 2025
@github-actions
Copy link

github-actions bot commented Sep 9, 2025

2025-09-09 11:06:53 UTC Pre-commit check linux-x86_64-release-asan for 9881884 has started.
2025-09-09 11:07:45 UTC Artifacts will be uploaded here
2025-09-09 11:11:35 UTC ya make is running...
2025-09-09 13:25:46 UTC Check cancelled

@github-actions
Copy link

github-actions bot commented Sep 9, 2025

🟢 2025-09-12 09:48:45 UTC The validation of the Pull Request description is successful.

@github-actions
Copy link

github-actions bot commented Sep 9, 2025

2025-09-09 11:21:42 UTC Pre-commit check linux-x86_64-relwithdebinfo for 9881884 has started.
2025-09-09 11:21:46 UTC Artifacts will be uploaded here
2025-09-09 11:25:19 UTC ya make is running...
🟡 2025-09-09 13:25:03 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?
30257 28855 0 12 1367 23

🟡 2025-09-09 13:25:50 UTC ydbd size 2.3 GiB changed* by +108.2 KiB, which is >= 100.0 KiB vs main: Warning

ydbd size dash main: 181055e merge: 9881884 diff diff %
ydbd size 2 444 389 808 Bytes 2 444 500 648 Bytes +108.2 KiB +0.005%
ydbd stripped size 511 707 048 Bytes 511 724 360 Bytes +16.9 KiB +0.003%

*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation
2025-09-09 13:25:52 UTC Check cancelled

@ztlpn ztlpn force-pushed the test-statistics-reboots branch from 17bf9ed to 53b4717 Compare September 9, 2025 13:25
@github-actions
Copy link

github-actions bot commented Sep 9, 2025

2025-09-09 13:32:12 UTC Pre-commit check linux-x86_64-relwithdebinfo for 9030153 has started.
2025-09-09 13:32:16 UTC Artifacts will be uploaded here
2025-09-09 13:35:38 UTC ya make is running...
🟡 2025-09-09 14:57:11 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?
30258 28854 0 4 1368 32

2025-09-09 14:59:48 UTC ya make is running... (failed tests rerun, try 2)
🟢 2025-09-09 15:21:24 UTC Tests successful.

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

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
263 (only retried tests) 240 0 0 0 23

🟢 2025-09-09 15:21:33 UTC Build successful.
🟢 2025-09-09 15:21:49 UTC ydbd size 2.3 GiB changed* by +83.6 KiB, which is < 100.0 KiB vs main: OK

ydbd size dash main: dc7aa6f merge: 9030153 diff diff %
ydbd size 2 444 467 792 Bytes 2 444 553 360 Bytes +83.6 KiB +0.004%
ydbd stripped size 511 719 528 Bytes 511 739 528 Bytes +19.5 KiB +0.004%

*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 Sep 9, 2025

2025-09-09 13:32:13 UTC Pre-commit check linux-x86_64-release-asan for 9030153 has started.
2025-09-09 13:32:17 UTC Artifacts will be uploaded here
2025-09-09 13:35:43 UTC ya make is running...
🟡 2025-09-09 15:29:45 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?
14847 14338 0 168 313 28

🟢 2025-09-09 15:31:03 UTC Build successful.
🟡 2025-09-09 15:31:29 UTC ydbd size 4.0 GiB changed* by +371.2 KiB, which is >= 100.0 KiB vs main: Warning

ydbd size dash main: 2eec194 merge: 9030153 diff diff %
ydbd size 4 296 112 056 Bytes 4 296 492 200 Bytes +371.2 KiB +0.009%
ydbd stripped size 1 489 222 552 Bytes 1 489 339 672 Bytes +114.4 KiB +0.008%

*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 Sep 9, 2025

std::unordered_map<TSSId, TString> BaseStatistics; // schemeshard id -> serialized stats for all paths
// Schemeshard id -> latest update from a tx that has not yet completed.
std::unordered_map<TSSId, std::shared_ptr<TString>> BaseStatisticsUpdateInflight;
Copy link
Member

Choose a reason for hiding this comment

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

Если честно мне не нравится этот временный unordered_map и то что в нём временный shared_ptr, хотя я и понимаю зачем ты его сделал. Можно ли сделать одну единую BaseStatistics? Например вида TSSId -> TSchemeShardStats, и там уже что-нибудь вроде:

struct TSchemeShardStats {
    std::shared_ptr<TString> Committed;
    std::shared_ptr<TString> Latest;
};

Это по идее упростит работу, искать schemeshard нужно будет только в одной хеш-таблице: в Execute транзакций смотрим и обновляем Latest, в Complete присваиваем в Committed, за пределами транзакций смотрим только на Committed (но учитываем, что он может быть nullptr даже если по SSId структура есть). На загрузке из локальной базы присваиваем и в Committed и в Latest. Или так придётся слишком много переделывать?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Да, можно так сделать, даже меньше кода получается

@github-actions
Copy link

github-actions bot commented Sep 11, 2025

2025-09-11 15:38:26 UTC Pre-commit check linux-x86_64-release-asan for 06cd899 has started.
2025-09-11 15:39:01 UTC Artifacts will be uploaded here
2025-09-11 15:42:55 UTC ya make is running...
🟡 2025-09-11 18:28:39 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?
14836 14316 0 218 266 36

🟢 2025-09-11 18:30:12 UTC Build successful.
🟢 2025-09-11 18:30:35 UTC ydbd size 4.0 GiB changed* by +17.1 KiB, which is < 100.0 KiB vs main: OK

ydbd size dash main: 4822a3d merge: 06cd899 diff diff %
ydbd size 4 318 803 144 Bytes 4 318 820 696 Bytes +17.1 KiB +0.000%
ydbd stripped size 1 493 361 112 Bytes 1 493 368 984 Bytes +7.7 KiB +0.001%

*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 Sep 11, 2025

2025-09-11 15:38:35 UTC Pre-commit check linux-x86_64-relwithdebinfo for 06cd899 has started.
2025-09-11 15:38:40 UTC Artifacts will be uploaded here
2025-09-11 15:42:10 UTC ya make is running...
🟡 2025-09-11 17:50:35 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?
30264 28859 0 1 1370 34

2025-09-11 17:54:11 UTC ya make is running... (failed tests rerun, try 2)
🟢 2025-09-11 18:23:02 UTC Tests successful.

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

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
404 (only retried tests) 384 0 0 0 20

🟢 2025-09-11 18:23:11 UTC Build successful.
🟢 2025-09-11 18:23:29 UTC ydbd size 2.3 GiB changed* by +11.0 KiB, which is < 100.0 KiB vs main: OK

ydbd size dash main: 4822a3d merge: 06cd899 diff diff %
ydbd size 2 468 928 664 Bytes 2 468 939 896 Bytes +11.0 KiB +0.000%
ydbd stripped size 515 860 360 Bytes 515 863 304 Bytes +2.9 KiB +0.001%

*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 removed the bugfix label Sep 12, 2025
@ztlpn ztlpn merged commit 8f51162 into ydb-platform:main Sep 12, 2025
15 checks passed
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.

3 participants