Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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 @@ -615,24 +615,11 @@ public void acceptIncomingVote(String player, String service) {
if (!pendingIncomingVotes.isAccepting()) {
getLogger().severe("Vote received after VotingPlugin proxy shutdown began; vote was not accepted for "
+ MinecraftUsernameValidator.sanitizeForLog(player));
return;
}
synchronized (reloadLock) {
if (!pendingIncomingVotes.isAccepting()) {
getLogger().severe("Vote received after VotingPlugin proxy shutdown began; vote was not accepted for "
+ MinecraftUsernameValidator.sanitizeForLog(player));
return;
}
pending = new PendingIncomingVote(UUID.randomUUID(), player, service, System.currentTimeMillis());
if (votingPluginProxy == null || !votingPluginProxy.retainIncomingVoteForRestart(pending)) {
getLogger().severe("Pending vote admission is full and durable overflow failed; vote was not accepted for "
+ MinecraftUsernameValidator.sanitizeForLog(player));
return;
}
votingPluginProxy.scheduleQueuedVoteReplay();
getLogger().warning("Pending vote admission is full; accepted vote was handed directly to durable recovery");
return;
} else {
getLogger().severe("Pending vote admission is full; vote was rejected instead of expanding durable recovery for "
+ MinecraftUsernameValidator.sanitizeForLog(player));
}
return;
Comment on lines +618 to +622

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Retain overflow votes instead of discarding them

When 4,096 votes remain pending—for example, while scheduler callbacks are being rejected—VoteEventBungee.onVote has already received the next Votifier event, but this branch returns without processing or persisting it and cannot signal backpressure to the sender. The vote and its rewards are therefore permanently lost; the identical Velocity branch has the same regression. Keep overflow within a bounded ownership mechanism that durably retains admitted events rather than merely logging and discarding them.

AGENTS.md reference: AGENTS.md:L183-L189

Useful? React with 👍 / 👎.

}
retryPendingIncomingVotes();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -477,24 +477,11 @@ public void acceptIncomingVote(String player, String service) {
if (!pendingIncomingVotes.isAccepting()) {
logger.error("Vote received after VotingPlugin proxy shutdown began; vote was not accepted for {}",
MinecraftUsernameValidator.sanitizeForLog(player));
return;
}
synchronized (reloadLock) {
if (!pendingIncomingVotes.isAccepting()) {
logger.error("Vote received after VotingPlugin proxy shutdown began; vote was not accepted for {}",
MinecraftUsernameValidator.sanitizeForLog(player));
return;
}
pending = new PendingIncomingVote(UUID.randomUUID(), player, service, System.currentTimeMillis());
if (votingPluginProxy == null || !votingPluginProxy.retainIncomingVoteForRestart(pending)) {
logger.error("Pending vote admission is full and durable overflow failed; vote was not accepted for {}",
MinecraftUsernameValidator.sanitizeForLog(player));
return;
}
votingPluginProxy.scheduleQueuedVoteReplay();
logger.warn("Pending vote admission is full; accepted vote was handed directly to durable recovery");
return;
} else {
logger.error("Pending vote admission is full; vote was rejected instead of expanding durable recovery for {}",
MinecraftUsernameValidator.sanitizeForLog(player));
}
return;
}
retryPendingIncomingVotes();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,23 @@ void rejectedSchedulerAdmissionLeavesVoteOwnedUntilDurableHandoff() throws Excep
assertEquals(0, pending.size());
}

@Test
void fullPendingAdmissionRejectsInsteadOfSpillingToDurableRecovery() throws Exception {
VotingPluginBungee plugin = mock(VotingPluginBungee.class, CALLS_REAL_METHODS);
VotingPluginProxy runtime = mock(VotingPluginProxy.class);
PendingIncomingVoteQueue queue = new PendingIncomingVoteQueue();
for (int i = 0; i < 4096; i++) assertTrue(queue.admit("Player" + i, "Service") != null);
setField(plugin, "pendingIncomingVotes", queue);
setField(plugin, "votingPluginProxy", runtime);
when(plugin.getLogger()).thenReturn(java.util.logging.Logger.getLogger("VotingPluginBungeeInitializationTest"));

plugin.acceptIncomingVote("Overflow", "Service");

assertEquals(4096, queue.size());
verify(runtime, never()).retainIncomingVoteForRestart(any(PendingIncomingVote.class));
verify(runtime, never()).scheduleQueuedVoteReplay();
}

@Test
void failedDurableHandoffSchedulesAnotherAttempt() throws Exception {
VotingPluginBungee plugin = mock(VotingPluginBungee.class, CALLS_REAL_METHODS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,23 @@ void rejectedExecutorAdmissionLeavesVoteOwnedUntilDurableHandoff(@TempDir Path d
assertEquals(0, pending.size());
}

@Test
void fullPendingAdmissionRejectsInsteadOfSpillingToDurableRecovery(@TempDir Path dataDirectory) throws Exception {
VotingPluginVelocity plugin = new VotingPluginVelocity(mock(ProxyServer.class), mock(Logger.class),
mock(Metrics.Factory.class), dataDirectory);
VotingPluginProxy runtime = mock(VotingPluginProxy.class);
PendingIncomingVoteQueue queue = (PendingIncomingVoteQueue) getField(plugin, "pendingIncomingVotes");
for (int i = 0; i < 4096; i++) assertTrue(queue.admit("Player" + i, "Service") != null);
setField(plugin, "votingPluginProxy", runtime);

plugin.acceptIncomingVote("Overflow", "Service");

assertEquals(4096, queue.size());
verify(runtime, never()).retainIncomingVoteForRestart(any(PendingIncomingVote.class));
verify(runtime, never()).scheduleQueuedVoteReplay();
plugin.getTimer().shutdownNow();
}

@Test
void failedDurableHandoffSchedulesAnotherAttempt(@TempDir Path dataDirectory) throws Exception {
VotingPluginVelocity plugin = new VotingPluginVelocity(mock(ProxyServer.class), mock(Logger.class),
Expand Down
Loading