Skip to content

Fall back when the encoder buffer pool is exhausted - #506

Merged
em3s merged 1 commit into
kakao:mainfrom
shin4141:codex/fix-pooled-buffer-exhaustion
Oct 12, 2026
Merged

em3s merged 1 commit into
kakao:mainfrom
shin4141:codex/fix-pooled-buffer-exhaustion

Conversation

@shin4141

@shin4141 shin4141 commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

What this fixes

When all pooled EdgeBuffer instances are in use, borrow() gets null from pool.poll() and the next encode throws at reset(). Allocate a new EdgeBuffer only for that exhausted-pool case. This is the follow-up invited by the maintainer on #505.

Why it matters

Concurrent encodes beyond poolSize can fail even though an independent buffer can encode the value.

Review scope

Two codec-java files: a fallback in AbstractEdgeEncoder.borrow() and one concurrency regression test. The pooled fast path and release behavior stay the same.

Evidence

  • On main at afa7143f1d8a0d16623eb5de3e963706ff819bba, the regression reproduces the second encode's NullPointerException at useAsByteArray:408.
  • With this patch, overlapping encodes use distinct buffers and both outputs match unpooled controls.
  • :codec-java:test: 68 passed; :codec-java:spotlessCheck: passed.
  • :core:test --tests '*V2BulkLoadAggregationTest*': 1 passed.
  • Full engine suite was not run for this follow-up and remains unverified.

AI Assistance

  • This change was written largely with AI assistance.
    • Tool / model: Codex (GPT-6).

@shin4141
shin4141 requested a review from em3s as a code owner October 2, 2026 14:16

@em3s em3s left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @shin4141 — clean fix, and the latch test shows the exhausted-pool case directly. LGTM, merging.

@em3s
em3s merged commit f9733ec into kakao:main Oct 12, 2026
3 checks passed
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.

2 participants