Skip to content
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

[server] Fix IndexOutOfBoundsException in memory usage in SBS #1426

Merged
merged 3 commits into from
Jan 11, 2025
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public class StoreBufferService extends AbstractStoreBufferService {

private final boolean isSorted;

private boolean isStarted = false;
majisourav99 marked this conversation as resolved.
Show resolved Hide resolved

public StoreBufferService(
int drainerNum,
long bufferCapacityPerDrainer,
Expand Down Expand Up @@ -308,12 +310,14 @@ public boolean startInner() {
drainerList.add(drainer);
}
this.executorService.shutdown();
isStarted = true;
return true;
}

@Override
public void stopInner() throws Exception {
// Graceful shutdown
isStarted = false;
drainerList.forEach(drainer -> drainer.stop());
if (this.executorService != null) {
this.executorService.shutdownNow();
Expand Down Expand Up @@ -344,6 +348,10 @@ public long getMaxMemoryUsagePerDrainer() {
long maxUsage = 0;
boolean slowDrainerExists = false;

if (!isStarted) {
return maxUsage;
}

for (MemoryBoundBlockingQueue<QueueNode> queue: blockingQueueArr) {
maxUsage = Math.max(maxUsage, queue.getMemoryUsage());
if (queue.getMemoryUsage() > 0.8 * bufferCapacityPerDrainer) {
Expand Down
Loading