-
Notifications
You must be signed in to change notification settings - Fork 14.8k
KAFKA-19519: Introduce group.coordinator.append.max.buffer.size config #20847
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Conversation
# Conflicts: # coordinator-common/src/test/java/org/apache/kafka/coordinator/common/runtime/CoordinatorRuntimeTest.java
squah-confluent
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the patch! I left a few comments. I haven't reviewed the full PR yet.
clients/src/main/java/org/apache/kafka/common/utils/BufferSupplier.java
Outdated
Show resolved
Hide resolved
| /** | ||
| * Return total size in bytes of cached buffers. | ||
| */ | ||
| public abstract long size(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The size implementations aren't thread safe, but they will be called from a metrics thread.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for pointing out this issue. As BufferSupplier is designed to be a "simple non-threadsafe interface for caching byte buffers," I've made the following targeted changes to address the specific concerns with the size() method when called from metrics threads:
- Changed the
bufferMapinDefaultSupplierto aConcurrentHashMapto prevent potentialConcurrentModificationException. - Added the
volatilekeyword tocachedBufferinGrowableBufferSupplierto resolve visibility issues.
I intentionally avoided adding synchronization to the get(), release(), and size() methods to maintain performance, as comprehensive thread safety isn't a design goal for this interface. These changes specifically address the metrics collection use case while preserving the lightweight. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updating the PR!
Avoiding locks is the right thing to do but the fixes do not look complete.
- The
ArrayDeques withinDefaultSuppliersuffer from the same visibility issue ascachedBuffer. - The first read of
cachedBufferwithinGrowableBufferSupplier.sizecan be non-nullwhile the second read can benull.
Instead I would propose we introduce a size AtomicLong and update them in get and release.
Changes
group.coordinator.append.max.buffer.size: Largest buffer size allowed by GroupCoordinatorshare.coordinator.append.max.buffer.size: Largest buffer size allowed by ShareCoordinatorBoth configurations default to
1 * 1024 * 1024 + Records.LOG_OVERHEADwith minimum value of512 * 1024.Added withMaxBufferSize(Supplier maxBufferSizeSupplier) method to allow different coordinator implementations to supply their buffer size configuration.
coordinator-append-buffer-size-bytes: Current total size in bytes of the append buffers being held in the coordinator's cachecoordinator-append-buffer-skip-cache-count: Count of oversized append buffers that were discarded instead of being cached upon release