Skip to content

Added support of direct write mode#641

Merged
alex268 merged 8 commits intoydb-platform:masterfrom
alex268:master
Apr 27, 2026
Merged

Added support of direct write mode#641
alex268 merged 8 commits intoydb-platform:masterfrom
alex268:master

Conversation

@alex268
Copy link
Copy Markdown
Member

@alex268 alex268 commented Apr 24, 2026

No description provided.

@alex268 alex268 requested a review from pnv1 April 24, 2026 11:04
@pnv1 pnv1 requested a review from Copilot April 24, 2026 11:05
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 24, 2026

Codecov Report

❌ Patch coverage is 94.47514% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.07%. Comparing base (8556216) to head (bdb9c8c).

Files with missing lines Patch % Lines
.../tech/ydb/topic/write/impl/WriteStreamFactory.java 95.57% 2 Missing and 3 partials ⚠️
...main/java/tech/ydb/topic/impl/TopicStreamFail.java 72.72% 3 Missing ⚠️
topic/src/main/java/tech/ydb/topic/TopicRpc.java 0.00% 1 Missing ⚠️
...rc/main/java/tech/ydb/topic/impl/GrpcTopicRpc.java 87.50% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #641      +/-   ##
============================================
+ Coverage     70.87%   71.07%   +0.20%     
- Complexity     3314     3341      +27     
============================================
  Files           374      377       +3     
  Lines         15699    15810     +111     
  Branches       1650     1662      +12     
============================================
+ Hits          11126    11237     +111     
+ Misses         3931     3927       -4     
- Partials        642      646       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Adds “direct write” support for topic writers by allowing write sessions to target a preferred node (derived from partition location), and refactors the internal stream abstraction to support both real and pre-failed streams.

Changes:

  • Introduce WriteStreamFactory to construct regular or direct-write streams (by partitionId or producerId).
  • Refactor TopicStream into an interface with concrete implementations TopicStreamBase and TopicStreamFail.
  • Add/adjust tests validating direct write behavior and the new stream base class usage.

Reviewed changes

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

Show a summary per file
File Description
topic/src/main/java/tech/ydb/topic/write/impl/WriteStreamFactory.java New factory implementing direct-write selection + partition/node probing logic.
topic/src/main/java/tech/ydb/topic/write/impl/WriteStream.java Switch to TopicStreamBase and add Fail stream implementation.
topic/src/main/java/tech/ydb/topic/write/impl/WriteSession.java Wire WriteStreamFactory into retryable write session creation.
topic/src/main/java/tech/ydb/topic/settings/WriterSettings.java Add direct write flag and builder setter.
topic/src/main/java/tech/ydb/topic/impl/TopicStream.java Convert from abstract class to interface.
topic/src/main/java/tech/ydb/topic/impl/TopicStreamBase.java New concrete base implementation wrapping grpc stream behavior.
topic/src/main/java/tech/ydb/topic/impl/TopicStreamFail.java New stream implementation that fails immediately with a fixed status.
topic/src/main/java/tech/ydb/topic/impl/GrpcTopicRpc.java Add writeSession(id, directWriteNodeId) with direct-mode request settings.
topic/src/main/java/tech/ydb/topic/TopicRpc.java Extend API with default overload for direct-write node targeting + proto type import cleanup.
topic/src/test/java/tech/ydb/topic/write/impl/WriteStreamFactoryTest.java New tests for direct write factory scenarios and failures.
topic/src/test/java/tech/ydb/topic/impl/TopicStreamTest.java Update test to use TopicStreamBase.
topic/src/test/java/tech/ydb/topic/impl/TopicRetryableStreamTest.java Update mocks/types to reflect new TopicStream interface/base.

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

Comment thread topic/src/main/java/tech/ydb/topic/settings/WriterSettings.java Outdated
Comment thread topic/src/main/java/tech/ydb/topic/settings/WriterSettings.java
Comment thread topic/src/main/java/tech/ydb/topic/impl/TopicStreamFail.java Outdated
Comment thread topic/src/main/java/tech/ydb/topic/write/impl/WriteStreamFactory.java Outdated
pnv1
pnv1 previously approved these changes Apr 24, 2026
Comment thread topic/src/main/java/tech/ydb/topic/write/impl/WriteStreamFactory.java Outdated
Comment thread topic/src/main/java/tech/ydb/topic/write/impl/WriteStreamFactory.java Outdated
Comment thread topic/src/main/java/tech/ydb/topic/write/impl/WriteStreamFactory.java Outdated
Copy link
Copy Markdown

@robot-vibe-db robot-vibe-db Bot left a comment

Choose a reason for hiding this comment

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

Overall: the refactoring from TopicStream (abstract class) to TopicStream (interface) + TopicStreamBase + TopicStreamFail is well-structured. The TopicStreamFail pattern integrates cleanly with the retry mechanism in TopicRetryableStream — when direct write setup fails, the failure status flows through the existing retry logic, so transient errors (e.g. UNAVAILABLE from describeTopic) get retried while non-retryable errors (e.g. BAD_REQUEST for missing partition) stop the writer. The test coverage for WriteStreamFactory is thorough and covers the important success and failure paths for both partition-id-based and producer-id-based direct write modes.

See inline comments for potential issues found during review.

Copy link
Copy Markdown

@robot-vibe-db robot-vibe-db Bot left a comment

Choose a reason for hiding this comment

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

Overall: the refactoring from TopicStream (abstract class) to TopicStream (interface) + TopicStreamBase + TopicStreamFail is well-structured. The TopicStreamFail pattern integrates cleanly with the retry mechanism in TopicRetryableStream — when direct write setup fails, the failure status flows through the existing retry logic, so transient errors (e.g. UNAVAILABLE from describeTopic) get retried while non-retryable errors (e.g. BAD_REQUEST for missing partition) stop the writer. The test coverage for WriteStreamFactory is thorough and covers the important success and failure paths for both partition-id-based and producer-id-based direct write modes.

See inline comments for potential issues found during review.

Comment thread topic/src/main/java/tech/ydb/topic/write/impl/WriteStreamFactory.java Outdated
Comment thread topic/src/main/java/tech/ydb/topic/TopicRpc.java
Copy link
Copy Markdown

@robot-vibe-db robot-vibe-db Bot left a comment

Choose a reason for hiding this comment

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

I reviewed the changes in context of the surrounding codebase. The PR restructures the write-side stream infrastructure — splitting TopicStream into an interface + base implementation + fail implementation, extracting StreamFactory from WriteSession into a standalone WriteStreamFactory, and adding direct write mode support. Overall the code flow is correct and test coverage is good. I found no critical issues in the changes.

A few non-critical observations below in inline comments.

Copy link
Copy Markdown

@robot-vibe-db robot-vibe-db Bot left a comment

Choose a reason for hiding this comment

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

No critical issues found in the code changes. The refactoring of the write-side stream infrastructure is well-structured and the direct write mode implementation is correct. A few non-critical observations below.

Comment thread topic/src/main/java/tech/ydb/topic/TopicRpc.java
@alex268 alex268 merged commit 24fe062 into ydb-platform:master Apr 27, 2026
10 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.

5 participants