Skip to content

Topic Writer Backpressure#797

Merged
vgvoleg merged 1 commit intomainfrom
writer_buffer_limit
Apr 6, 2026
Merged

Topic Writer Backpressure#797
vgvoleg merged 1 commit intomainfrom
writer_buffer_limit

Conversation

@vgvoleg
Copy link
Copy Markdown
Collaborator

@vgvoleg vgvoleg commented Mar 31, 2026

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

Fixes: #694
Fixes: #137
Fixes: #136

What is the new behavior?

Other information

Copy link
Copy Markdown

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 PR introduces configurable backpressure for the Topic Writer by adding a byte-size limit for the internal in-flight buffer and making writes block (up to a timeout) until space is freed by server acks.

Changes:

  • Add max_buffer_size_bytes and buffer_wait_timeout_sec to writer settings and enforce them in WriterAsyncIOReconnector.write_with_ack_future().
  • Add a new public exception TopicWriterBufferFullError surfaced via ydb.topic.
  • Add sync/async tests and an example showing how to use the buffer limit.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
ydb/topic.py Exports the new TopicWriterBufferFullError as part of the public Topic API.
ydb/_topic_writer/topic_writer.py Adds settings fields, new exception type, and a helper for message size accounting.
ydb/_topic_writer/topic_writer_asyncio.py Implements buffer accounting + backpressure wait loop and updates ack handling/shutdown behavior.
ydb/_topic_writer/topic_writer_test.py Adds sync writer tests around error propagation/blocking behavior.
ydb/_topic_writer/topic_writer_asyncio_test.py Adds async tests for timeout, ack-unblocking, and concurrent waiting writers.
examples/topic/writer_example.py Documents how to configure and handle backpressure in user code.

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

Comment thread ydb/_topic_writer/topic_writer.py Outdated
Comment thread ydb/_topic_writer/topic_writer_asyncio.py Outdated
Comment thread ydb/_topic_writer/topic_writer_asyncio.py Outdated
Comment thread ydb/_topic_writer/topic_writer_asyncio.py
@vgvoleg vgvoleg force-pushed the writer_buffer_limit branch 2 times, most recently from 6e60736 to b52cbb3 Compare April 6, 2026 09:40
@vgvoleg vgvoleg requested a review from Copilot April 6, 2026 09:43
Copy link
Copy Markdown

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

Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.


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

Comment thread ydb/topic.py
Comment thread docs/topic.rst
Comment thread examples/topic/writer_example.py
Comment thread ydb/_topic_writer/topic_writer_asyncio.py
Comment thread ydb/_topic_writer/topic_writer_asyncio.py
Comment thread ydb/_topic_writer/topic_writer_asyncio_test.py Outdated
Comment thread docs/topic.rst Outdated
Copy link
Copy Markdown

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

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.


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

Comment thread ydb/_topic_writer/topic_writer.py Outdated
Comment thread docs/topic.rst
Comment thread ydb/_topic_writer/topic_writer_asyncio.py
Comment thread ydb/topic.py Outdated
@vgvoleg vgvoleg force-pushed the writer_buffer_limit branch 2 times, most recently from faf5242 to 25f24bc Compare April 6, 2026 13:56
@vgvoleg vgvoleg requested a review from Copilot April 6, 2026 14:07
Copy link
Copy Markdown

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

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.


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

Comment thread ydb/_topic_writer/topic_writer.py
Comment thread ydb/_topic_writer/topic_writer_test.py Outdated
@vgvoleg vgvoleg force-pushed the writer_buffer_limit branch 4 times, most recently from c242e73 to 875c541 Compare April 6, 2026 15:34
@vgvoleg vgvoleg force-pushed the writer_buffer_limit branch from 875c541 to c5cea59 Compare April 6, 2026 15:43
@vgvoleg vgvoleg merged commit cfafbd8 into main Apr 6, 2026
33 of 34 checks passed
@vgvoleg vgvoleg deleted the writer_buffer_limit branch April 6, 2026 15:55
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.

bug: Support internal buffer limit by memory for writer Support internal buffer limit by message count for writer

3 participants