Skip to content

Making CodecRegistry thread-safe - #688

Open
Myllyenko wants to merge 1 commit into
ydb-platform:masterfrom
Myllyenko:fix/codec-registry-thread-safety
Open

Making CodecRegistry thread-safe#688
Myllyenko wants to merge 1 commit into
ydb-platform:masterfrom
Myllyenko:fix/codec-registry-thread-safety

Conversation

@Myllyenko

Copy link
Copy Markdown

One CodecRegistry instance is shared by every reader and writer created from a TopicClient. getCodec is called from the compression threads (WriterQueue), from the decompression threads (MessageDecoder via Encoder.decode) and from gRPC callbacks, while registerCodec is public API that may be called at any time. Backing that with a plain HashMap (current implementation) means concurrent puts can lose entries or corrupt the table.

@Myllyenko
Myllyenko force-pushed the fix/codec-registry-thread-safety branch from c90ea64 to 216423b Compare August 5, 2026 21:19
One CodecRegistry instance is shared by every reader and writer created
from a TopicClient. getCodec is called from the compression threads
(WriterQueue), from the decompression threads (MessageDecoder via
Encoder.decode) and from gRPC callbacks, while registerCodec is public
API that may be called at any time. Backing that with a plain HashMap
means concurrent puts can lose entries or corrupt the table.

Use a ConcurrentHashMap. The new test loses codecs on every run with the
old implementation.
@Myllyenko
Myllyenko force-pushed the fix/codec-registry-thread-safety branch from 216423b to 87390cb Compare August 5, 2026 21:36
@codecov

codecov Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.94%. Comparing base (d876581) to head (87390cb).

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #688      +/-   ##
============================================
+ Coverage     71.91%   71.94%   +0.03%     
- Complexity     3474     3478       +4     
============================================
  Files           390      390              
  Lines         16220    16220              
  Branches       1698     1698              
============================================
+ Hits          11664    11669       +5     
+ Misses         3904     3903       -1     
+ Partials        652      648       -4     

☔ View full report in Codecov by Harness.
📢 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.

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.

1 participant