Skip to content

Conversation

@muir
Copy link
Collaborator

@muir muir commented Dec 9, 2025

With this change, per topic and broker size limits are discovered and used to prevent oversize messages from being sent. Previously, when using transactional produce, messages could be queued that couldn't be sent. This would clog things up. Now, such messages are stopped early and and error is returned.

Resolves #83

On top of #105

@muir muir requested a review from mitchwadair December 9, 2025 01:16
@codecov-commenter
Copy link

codecov-commenter commented Dec 9, 2025

Codecov Report

❌ Patch coverage is 75.42533% with 130 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.50%. Comparing base (b32e53e) to head (7fd3672).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
limits.go 62.21% 55 Missing and 27 partials ⚠️
internal/pwork/pwork.go 64.17% 19 Missing and 5 partials ⚠️
connection.go 69.38% 9 Missing and 6 partials ⚠️
internal/multi/multi.go 93.40% 4 Missing and 2 partials ⚠️
eventtest/common.go 81.81% 1 Missing and 1 partial ⚠️
eventtest/oversize.go 98.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #99      +/-   ##
==========================================
+ Coverage   76.22%   76.50%   +0.28%     
==========================================
  Files          32       35       +3     
  Lines        4076     4529     +453     
==========================================
+ Hits         3107     3465     +358     
- Misses        776      834      +58     
- Partials      193      230      +37     
Flag Coverage Δ
go_tests 4.01% <16.82%> (+1.73%) ⬆️
nodb_tests 59.95% <70.88%> (+2.66%) ⬆️
pg_tests 74.71% <72.02%> (+0.40%) ⬆️
s2_tests 74.67% <72.02%> (+0.40%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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
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

This PR implements per-topic and broker size limits discovery to prevent oversize messages from being sent, particularly in transactional produce scenarios where oversized messages would previously clog the system. The feature proactively fetches and enforces Kafka broker and topic-level message size limits, returning early errors for messages that exceed these limits.

Key changes:

  • New size cap subsystem that asynchronously discovers broker and per-topic message size limits
  • Integration of batch processing support in the pwork worker pool via ItemsWork
  • Introduction of multi.Context for managing multiple contexts in long-running background operations

Reviewed changes

Copilot reviewed 17 out of 18 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
limits.go New file implementing size cap discovery and enforcement, including broker-level and topic-level limit fetching and validation
produce.go Integrates prepareToProduce to check message sizes before sending, replacing the previous topic creation approach
topics.go Removes createTopicsForOutgoingEvents function, now handled by prepareToProduce
internal/pwork/pwork.go Adds ItemsWork field for batch processing multiple items together, with context sharing via multi.Context
internal/multi/multi.go New multi-context implementation that remains active as long as any constituent context is active
connection.go Adds size cap subsystem fields and helper methods (getABrokerID, getBrokers, findABroker)
eventtest/oversize.go New test validating size limit enforcement across topics with different limits
eventtest/happy_path.go Shortens consumer group names to avoid length issues
eventtest/common.go Improves test name generation, increases timeouts, adds oversize test to matrix
eventtest/dead_letter.go Adds logging for consumer group name
consume.go Adds clarifying comments for waitgroup increment tracking
go.mod, go.sum Adds github.com/chrismcguire/gobberish dependency for test data generation
id_allocator_test.go Minor formatting improvements (whitespace cleanup)
events2/shared_test.go, eventpg/shared_test.go, eventnodb/shared_test.go Adds logging at test start
consumer_group_test.go Adds logging at test start

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

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

Copilot reviewed 17 out of 18 changed files in this pull request and generated 9 comments.


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

@muir muir requested a review from S2BryanW January 7, 2026 05:54
Copy link
Collaborator

@S2BryanW S2BryanW left a comment

Choose a reason for hiding this comment

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

Lots of complex code that I could not review in detail. General flow seems OK, but check comments.

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

Copilot reviewed 18 out of 19 changed files in this pull request and generated 2 comments.


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

@muir muir merged commit b5b313a into main Jan 21, 2026
16 checks passed
muir added a commit that referenced this pull request Jan 21, 2026
On top of #99 

This changes the tracer API from passing in a Logf function to instead
passing in a function that returns a Logf function given a context.
It also introduces an optional TracerConfig that allows spans to be put
into context.

Specifically:
- `Configure` now takes a `TracerProvider` instead of a `Tracer`
- Library now supports: `SetTracerConfig(TracerConfig)` to allow spans
to be put into contexts

The above change is the only API change that is likely to cause breakage
but there are more:

Additionally:
- `eventmodels.LibraryInterface` has more methods
- `eventmodels.HandlerInfo` has more methods
- `eventmodels.CanValidateTopics` was removed
- `eventpg.ProduceDroppedTxEvents` no longer takes a tracer
- `eventpg.SaveEventsInsideTx` no longer takes a tracer and takes an
`eventmodels.Producer` instead of a `CanValidateTopics`
- `events2.Connection.SaveEventsInsideTx` no longer takes a tracer
- `events2.ProduceDroppedTxEvents` no longer takes a tracer
- `events2.SaveEventsInsideTx` no longer takes a tracer and takes an
`eventmodels.Producer` instead of a `CanValidateTopics`


Other changes:
- some `eventtest` code moved to `eventtest/eventtestutil`
- `internal/multi` was removed
- lifetimes are now more carefully tracked so that spans can be closed
- `Libary.Shutdown()` was added so that tests could easily wait for the
library to completely terminate
- Now depends on a new version of the simultaneous library
- threadContext() is introduced for getting span contexts for background
threads
- New debug environment variable: EVENTS_DEBUG_CONSUME_STOP
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.

reject oversize messages

4 participants