Skip to content

Conversation

@a-serebryanskiy
Copy link
Collaborator

@a-serebryanskiy a-serebryanskiy commented May 6, 2025

Changelog entry

Issue: #18116

This PR fixes optimisation in NKikimr::NRawSocket::TBufferedWriter, that wrote the entire message directly to socket if message was larger than available space in buffer. When we wrote more than 6mb to socket with SSL enabled, it every time returned -11 (WAGAIN).
As a quick fix, we replace sending of an entire message to socket with cutting this message into 1mb chunks and sending them to socket one by one.

Changelog category

  • Bugfix

Description for reviewers

...

@a-serebryanskiy a-serebryanskiy requested a review from a team as a code owner May 6, 2025 12:13
@github-actions
Copy link

github-actions bot commented May 6, 2025

🟢 2025-05-07 09:40:30 UTC The validation of the Pull Request description is successful.

if (left > Buffer.Capacity()) {
// we send only buffer capacity, cause we know for sure that it will be written to socket without error
// there was a bug when we wrote to socket in one big batch and OS closed the connection if message was bigger than 6mb and SSL was enabled
ssize_t sendRes = Socket->Send(src + offset, Buffer.Capacity());
Copy link
Collaborator

Choose a reason for hiding this comment

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

А почему мы здесь берем размер буффера?
Не окажется ли эффективней взять, например, 1Mb?

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 May 6, 2025

2025-05-06 12:48:42 UTC Pre-commit check linux-x86_64-release-asan for a01e245 has started.
2025-05-06 12:49:12 UTC Artifacts will be uploaded here
2025-05-06 12:52:44 UTC ya make is running...
2025-05-06 13:14:08 UTC Check cancelled

Buffer.flush();
ssize_t res = Buffer.flush();
if (res < 0) {
ythrow yexception() << "Error during flush of the written to socket data. Error code: " << strerror(-res) << " (" << res << ")" << ".";
Copy link
Collaborator

Choose a reason for hiding this comment

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

вроде точка лишняя. везде без точки в конце предложения , но можешь проверить :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

0 это тоже ошибка (после изменений в Send надо проверить может ли возвращаться 0)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

вроде точка лишняя. везде без точки в конце предложения , но можешь проверить :)

Это все GPT) Поправлю

void TKafkaWritable::write(const char* val, size_t length) {
Buffer.write(val, length);
ssize_t res = Buffer.write(val, length);
if (res < 0) {
Copy link
Collaborator

@nshestakov nshestakov May 6, 2025

Choose a reason for hiding this comment

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

0 это тоже ошибка (после изменений в Send надо проверить может ли возвращаться 0)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Если 0 считать ошибкой, падают все тесты. Оставлю пока как есть и заведу тикет, чтобы разобраться в этом позже.


private:
const ui32 MAX_RETRY_ATTEMPTS = 3;
const size_t MAX_SOCKET_BATCH_SIZE = 1 * 1024 * 1024; // 1 mb
Copy link
Collaborator

Choose a reason for hiding this comment

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

1_MB можно использовать вместо 1 * 1024 * 1024

Copy link
Collaborator

Choose a reason for hiding this comment

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

и лучше static constexpr

@github-actions
Copy link

github-actions bot commented May 6, 2025

2025-05-06 13:25:08 UTC Pre-commit check linux-x86_64-release-asan for 1430477 has started.
2025-05-06 13:26:04 UTC Artifacts will be uploaded here
2025-05-06 13:29:30 UTC ya make is running...
2025-05-06 14:04:17 UTC Check cancelled

@github-actions
Copy link

github-actions bot commented May 6, 2025

2025-05-06 14:13:19 UTC Pre-commit check linux-x86_64-release-asan for 76ab3d9 has started.
2025-05-06 14:13:43 UTC Artifacts will be uploaded here
2025-05-06 14:16:40 UTC ya make is running...
2025-05-06 14:29:47 UTC Check cancelled

@github-actions
Copy link

github-actions bot commented May 6, 2025

2025-05-06 14:37:46 UTC Pre-commit check linux-x86_64-relwithdebinfo for 5b832c2 has started.
2025-05-06 14:37:56 UTC Artifacts will be uploaded here
2025-05-06 14:40:40 UTC ya make is running...
🟡 2025-05-06 15:48:34 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?
22327 20964 0 2 1323 38

2025-05-06 15:50:21 UTC ya make is running... (failed tests rerun, try 2)
🟡 2025-05-06 16:08:54 UTC Some tests failed, follow the links below. Going to retry failed tests...

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

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
563 (only retried tests) 529 0 1 0 33

2025-05-06 16:09:07 UTC ya make is running... (failed tests rerun, try 3)
🟢 2025-05-06 16:35:23 UTC Tests successful.

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

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
116 (only retried tests) 85 0 0 0 31

🟢 2025-05-06 16:35:32 UTC Build successful.
🟢 2025-05-06 16:35:54 UTC ydbd size 2.2 GiB changed* by -499.8 KiB, which is <= 0 Bytes vs main: OK

ydbd size dash main: 97ed61a merge: 5b832c2 diff diff %
ydbd size 2 344 087 568 Bytes 2 343 575 816 Bytes -499.8 KiB -0.022%
ydbd stripped size 493 122 176 Bytes 493 017 024 Bytes -102.7 KiB -0.021%

*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 May 6, 2025

2025-05-06 14:38:17 UTC Pre-commit check linux-x86_64-release-asan for 5b832c2 has started.
2025-05-06 14:38:28 UTC Artifacts will be uploaded here
2025-05-06 14:41:20 UTC ya make is running...
🟡 2025-05-06 16:10:17 UTC Some tests failed, follow the links below. This fail is not in blocking policy yet Going to retry failed tests...

Test history | Ya make output | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
14516 14344 0 97 49 26

2025-05-06 16:11:30 UTC ya make is running... (failed tests rerun, try 2)
🟡 2025-05-06 16:43:02 UTC Some tests failed, follow the links below. This fail is not in blocking policy yet Going to retry failed tests...

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

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
1324 (only retried tests) 1226 0 49 23 26

2025-05-06 16:43:18 UTC ya make is running... (failed tests rerun, try 3)
🟡 2025-05-06 17:16:16 UTC Some tests failed, follow the links below. This fail is not in blocking policy yet

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

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
1160 (only retried tests) 1059 0 50 25 26

🟢 2025-05-06 17:16:31 UTC Build successful.
🟢 2025-05-06 17:17:03 UTC ydbd size 3.8 GiB changed* by -1.2 MiB, which is <= 0 Bytes vs main: OK

ydbd size dash main: 97ed61a merge: 5b832c2 diff diff %
ydbd size 4 127 606 216 Bytes 4 126 329 640 Bytes -1.2 MiB -0.031%
ydbd stripped size 1 433 427 832 Bytes 1 432 973 560 Bytes -443.6 KiB -0.032%

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

@a-serebryanskiy a-serebryanskiy merged commit 7fd0265 into ydb-platform:main May 7, 2025
14 of 15 checks passed
a-serebryanskiy added a commit to a-serebryanskiy/ydb that referenced this pull request May 7, 2025
Co-authored-by: Nikolay Shestakov <n.shestakov@gmail.com>
a-serebryanskiy added a commit to a-serebryanskiy/ydb that referenced this pull request May 7, 2025
Co-authored-by: Nikolay Shestakov <n.shestakov@gmail.com>
a-serebryanskiy added a commit to a-serebryanskiy/ydb that referenced this pull request May 7, 2025
Co-authored-by: Nikolay Shestakov <n.shestakov@gmail.com>
@github-actions github-actions bot added bugfix and removed bugfix labels May 7, 2025
a-serebryanskiy added a commit to a-serebryanskiy/ydb that referenced this pull request May 7, 2025
Co-authored-by: Nikolay Shestakov <n.shestakov@gmail.com>
@a-serebryanskiy a-serebryanskiy changed the title fix sending big messages Fix reading big messages in Kafka Proxy May 7, 2025
@github-actions github-actions bot added bugfix and removed bugfix labels May 7, 2025
a-serebryanskiy added a commit that referenced this pull request May 7, 2025
…ig-messages-hotfix-24-4

Fix reading big messages in Kafka Proxy (from #18079)
a-serebryanskiy added a commit that referenced this pull request May 7, 2025
…ig-messages-hotfix-24-4-4

Fix reading big messages in Kafka Proxy (from #18079)
a-serebryanskiy added a commit that referenced this pull request May 7, 2025
…ig-messages-hotfix-25-1-1

Fix reading big messages in Kafka Proxy (from #18079)
a-serebryanskiy added a commit that referenced this pull request May 7, 2025
…ig-messages-hotfix-25-1

Fix reading big messages in Kafka Proxy (from #18079)
a-serebryanskiy added a commit to a-serebryanskiy/ydb that referenced this pull request Jul 13, 2025
Co-authored-by: Nikolay Shestakov <n.shestakov@gmail.com>
@liruoko liruoko added the changelog/f25-3 PR участвует в списке изменений label Nov 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix changelog/f25-3 PR участвует в списке изменений

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants