-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[improve][broker] Part-1 of PIP-434: Expose Netty channel configuration WRITE_BUFFER_WATER_MARK to pulsar conf and pause receive requests when channel is unwritable #24423
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
Merged
lhotari
merged 33 commits into
apache:master
from
poorbarcode:fix/broker_oom_pending_write
Sep 24, 2025
Merged
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
9a301b1
[fix][broker]Broker OOM because ServerCnx handling too many pending w…
poorbarcode 4b05c3f
1
poorbarcode bf2fe95
1
poorbarcode 6a507ac
pendingCmdByes
poorbarcode a93a786
-
poorbarcode d4862ab
PIP-434
poorbarcode d4eeee4
address comments
poorbarcode a8bb760
address comment
poorbarcode aabc89e
checkstyle
poorbarcode 961ca07
address comment
poorbarcode b5b68b3
checkstyle
poorbarcode 99751e9
change log level
poorbarcode 0367247
improve logs
poorbarcode da2c54d
address comment
poorbarcode 7399164
address comment
poorbarcode 680340d
address comment
poorbarcode 84c42d3
address comment
poorbarcode 6dd12dd
rename pulsarChannelFailureCooldownSeconds
poorbarcode 9d59608
rename pulsarChannelUnReadableCooldownSeconds
poorbarcode 9ceaaa3
checkstyle
poorbarcode d87c3a2
checkstyle
poorbarcode 6ce132b
address comments
poorbarcode fcb62a3
address comments
poorbarcode 4145f1e
checkstyle
poorbarcode 1e53c20
address comments
poorbarcode 94c91b5
checkstyle
poorbarcode 020fa41
address comments
poorbarcode 61e0c48
address comments
poorbarcode b711abd
checkstyle
poorbarcode 32424ce
address comments
poorbarcode 02cc0ea
address comments
poorbarcode 454438a
address comments
poorbarcode 3b36906
address comments
poorbarcode File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
pulsar-broker/src/main/java/org/apache/pulsar/utils/TimedSingleThreadRateLimiter.java
lhotari marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| package org.apache.pulsar.utils; | ||
|
|
||
| import java.util.concurrent.TimeUnit; | ||
| import lombok.Getter; | ||
| import lombok.extern.slf4j.Slf4j; | ||
|
|
||
| @Slf4j | ||
| public class TimedSingleThreadRateLimiter { | ||
|
|
||
| @Getter | ||
| private final int rate; | ||
| @Getter | ||
| private final long periodAtMs; | ||
| private long lastTimeReset; | ||
| @Getter | ||
| private int remaining; | ||
| private long closeAfterAtMs; | ||
|
|
||
| public TimedSingleThreadRateLimiter(final int rate, final long period, final TimeUnit unit) { | ||
| this.rate = rate; | ||
| this.periodAtMs = unit.toMillis(period); | ||
| this.lastTimeReset = System.currentTimeMillis(); | ||
| this.remaining = rate; | ||
| } | ||
|
|
||
| public int acquire(int permits) { | ||
| final long now = System.currentTimeMillis(); | ||
| if (permits < 0) { | ||
| return 0; | ||
| } | ||
| if (now > closeAfterAtMs) { | ||
| return permits; | ||
| } | ||
| mayRenew(now); | ||
| if (remaining > permits) { | ||
| remaining -= permits; | ||
| if (log.isDebugEnabled()) { | ||
| log.debug("acquired: {}, remaining:{}", permits, remaining); | ||
| } | ||
| return permits; | ||
| } else { | ||
| int acquired = remaining; | ||
| remaining = 0; | ||
| if (log.isDebugEnabled()) { | ||
| log.debug("acquired: {}, remaining:{}", acquired, remaining); | ||
| } | ||
| return acquired; | ||
| } | ||
| } | ||
|
|
||
| public void timingOpen(long closeAfter, final TimeUnit unit) { | ||
| if (closeAfter <= 0) { | ||
| this.closeAfterAtMs = 0; | ||
| } else { | ||
| this.closeAfterAtMs = System.currentTimeMillis() + unit.toMillis(closeAfter); | ||
| } | ||
| } | ||
|
|
||
| private void mayRenew(long now) { | ||
| if (now > lastTimeReset + periodAtMs) { | ||
| remaining = rate; | ||
| lastTimeReset = now; | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.