Skip to content

Conversation

@xy2953396112
Copy link
Contributor

…, support setting the Buffer for fileInfo.

What changes were proposed in this pull request?

When a flushBuffer consolidation OOM exception occurs, support setting the Buffer for fileInfo.

Why are the changes needed?

When a flushBuffer consolidation OOM exception occurs, the current logic does not allow setting the Buffer for fileInfo.

Does this PR resolve a correctness bug?

NO

Does this PR introduce any user-facing change?

NO

How was this patch tested?

CI

flushBuffer.consolidate()
fileInfo.setBuffer(flushBuffer)
try {
flushBuffer.consolidate()
Copy link
Contributor

Choose a reason for hiding this comment

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

Is flushBuffer safe when call consolidate encounter OutOfMemoryError?

Copy link
Contributor Author

@xy2953396112 xy2953396112 Dec 7, 2025

Choose a reason for hiding this comment

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

Even if the consolidate() method fails, the flushBuffer object itself remains valid.When CompositeByteBuf encounters an OutOfMemoryError, it will not be corrupted; only the memory consolidation operation fails to complete. the data integrity of flushBuffer is guaranteed, and it can be safely used continuously.

Copy link
Contributor

Choose a reason for hiding this comment

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

An OutOfMemoryError exception only occurs when the allocBuffer method is called in CompositeByteBuf#consolidate0. Before this, the internal data structure of CompositeByteBuf has not been modified, so even if consolidate throws an exception, the original buffer can still be used.

@xy2953396112
Copy link
Contributor Author

@TheodoreLx Please help review this PR. Thanks.

Copy link
Contributor

@TheodoreLx TheodoreLx left a comment

Choose a reason for hiding this comment

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

LGTM

flushBuffer.consolidate()
fileInfo.setBuffer(flushBuffer)
try {
flushBuffer.consolidate()
Copy link
Contributor

Choose a reason for hiding this comment

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

An OutOfMemoryError exception only occurs when the allocBuffer method is called in CompositeByteBuf#consolidate0. Before this, the internal data structure of CompositeByteBuf has not been modified, so even if consolidate throws an exception, the original buffer can still be used.

@RexXiong RexXiong closed this in 2dd1b7a Jan 2, 2026
@RexXiong
Copy link
Contributor

RexXiong commented Jan 2, 2026

Thanks. merge to main(v0.7.0)

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