nodece opened a new pull request, #26160:
URL: https://github.com/apache/pulsar/pull/26160

   ### Motivation
   
   PR #25337 migrated broker delayed-delivery protos from protobuf-java to 
LightProto. Unlike protobuf-java which eagerly copies bytes fields, LightProto 
lazily references the parsed ByteBuf. The existing `parseSnapshotMetadataEntry` 
released the buffer immediately after parsing, so any later access to 
`delayed_index_bit_map` entries (via `forEachDelayedIndexBitMap`) threw 
`IllegalReferenceCountException` (refCnt: 0).
   
   This caused `BucketDelayedDeliveryTracker` recovery to fail on every broker 
restart, silently falling back to `InMemoryDelayedDeliveryTracker` — all bucket 
snapshots became unreachable, bucket-level metrics disappeared, and new 
snapshots were no longer created.
   
   ### Modifications
   
   * Force materialization of `delayed_index_bit_map` entries into standalone 
`byte[]` copies before releasing the entry buffer in 
`parseSnapshotMetadataEntry`.
   * Add `testParseSnapshotMetadataEntryMaterializesLazyBytes` that reproduces 
the bug by mocking `LedgerEntry` with a refCnt=1 buffer (matching real BK, 
unlike `MockedBookKeeper` which masks the bug with an extra reference).
   
   ### Verifying
   
   The test fails without the fix (`IllegalReferenceCountException: refCnt: 0`) 
and passes with it.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to