Skip to content

Retry failed vote forwarding in memory - #195

Merged
BenCodez merged 2 commits into
masterfrom
cez/a3eaa45e
Nov 25, 2026
Merged

BenCodez merged 2 commits into
masterfrom
cez/a3eaa45e

Conversation

@BenCodez

@BenCodez BenCodez commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Retry eligible pre-write transport failures per vote and destination. Use 15-minute delays for retries one through five and 30-minute delays thereafter.
  • Limit pending retries to 256 pairs in receiver memory. Discard them at receiver retirement. There is no restart replay.
  • Recheck the destination and use current credentials on each retry. Cancel active retry sockets on retirement and avoid retrying after a write starts because delivery may already have occurred.

Verification

  • Focused forwarding, receiver lifecycle, protocol, and logging tests passed on Java 21 (48 tests). The retry tests stepped the scheduler through both intervals without waiting for them and covered failure isolation, DNS timeouts, credential rotation, recovery, and retirement during an active write.
  • The Java 21 Maven package build passed all 181 tests locally and on GitHub Actions. The fresh shaded JAR passed archive integrity checks and contains the retry classes and Bukkit, BungeeCord, and Velocity descriptors.
  • Independent source review approved the published range from 8e861dfd to b763d9ff.

Runtime limits

  • The retry worker shares the existing outbound socket limits. It schedules at most 256 pending vote–destination pairs, and when the queue is full, new failures cannot be added.
  • Reload or shutdown clears pending retries. The queue is RAM-only, with no restart replay. Failures after a payload write starts are terminal because the forwarding protocols provide no delivery acknowledgement.
  • No Minecraft runtime test was performed for Bukkit, Paper, Folia, BungeeCord, or Velocity.

Summary by CodeRabbit

  • New Features
    • Vote forwarding now retries eligible temporary failures, starting after 15 minutes and continuing every 30 minutes. Retries use the destination’s current credentials and are limited to 256 queued items.
    • Retries are skipped when a destination is removed, disabled, or changed, and queued retries are discarded when the service reloads or shuts down.
  • Documentation
    • Added guidance on retry timing, eligibility, terminal errors, queue limits, and when queued retries are discarded.

@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Vote forwarding now retries eligible initial failures through a bounded queue. Retries use the saved vote and current destination credentials, stop when the destination no longer matches, and are cancelled during shutdown.

Changes: Forwarding retries

Layer / File(s) Summary
Retry scheduling and forwarding
README.md, VotifierPlus/src/main/java/com/vexsoftware/votifier/net/VoteForwarder.java, VotifierPlus/src/test/java/com/bencodez/votifierplus/tests/net/VoteForwarderRetryTest.java
VoteForwarder queues eligible initial failures within the configured limit and retries after 15 minutes for the first five attempts, then every 30 minutes. Retries check the destination configuration and use current credentials. Tests cover retry eligibility, timing, target changes, capacity, and vote snapshots. The README documents the retry rules.
Attempt admission and retirement
VotifierPlus/src/main/java/com/vexsoftware/votifier/net/VoteForwarder.java, VotifierPlus/src/test/java/com/bencodez/votifierplus/tests/net/VoteForwarderHandshakeTest.java, VotifierPlus/src/test/java/com/bencodez/votifierplus/tests/net/VoteForwarderRetryTest.java
Attempt registration now uses Origin values. Shutdown stops retry scheduling, adjusts pending counts, closes active retry attempts, and waits for retry executor termination. Tests cover origin-aware registration and retirement of an active retry.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant VoteForwarder
  participant RetryExecutor
  participant Receiver
  participant TargetServer
  VoteForwarder->>TargetServer: Attempt initial forwarding
  TargetServer-->>VoteForwarder: Return eligible pre-write failure
  VoteForwarder->>RetryExecutor: Schedule retry
  RetryExecutor->>VoteForwarder: Run retry
  VoteForwarder->>Receiver: Check active state and current target configuration
  VoteForwarder->>TargetServer: Resolve, connect, handshake, and send
Loading

Possibly related PRs

  • BenCodez/VotifierPlus#194: Changes the same VoteForwarder retirement lifecycle by closing outbound sockets and bounding forwarding attempts.
Merge Risk: Minimal · up to b763d

The change adds bounded in-memory retries for eligible pre-write forwarding failures and cancels them on shutdown. No concrete defect was found in the retry queue limit, retirement handling or non-retry of ambiguous writes. It looks mergeable once the usual test and build checks pass.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "Retry failed vote forwarding in memory" matches the main change. The changeset adds bounded in-memory retries for retryable vote forwarding failures in VoteForwarder, with a 256-item limit …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title "Retry failed vote forwarding in memory" matches the main change. The changeset adds bounded in-memory retries for retryable vote forwarding failures in VoteForwarder, with a 256-item limit and retry scheduling. The title is concise and names the primary behavior. It does not mention the retry timing, the handshake changes, or the origin refactor, but those details are not required in a title.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8bba628e-dc07-42ba-bb03-292db7884eef
Commits

Reviewing files that changed from the base of the PR and between 8e861df and b763d9f.

Files selected for processing: 4

  • README.md
  • VotifierPlus/src/main/java/com/vexsoftware/votifier/net/VoteForwarder.java
  • VotifierPlus/src/test/java/com/bencodez/votifierplus/tests/net/VoteForwarderHandshakeTest.java
  • VotifierPlus/src/test/java/com/bencodez/votifierplus/tests/net/VoteForwarderRetryTest.java

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Recent review details

Context from checks skipped due to timeout: 1

  • GitHub Check: build
Additional context used

Learnings: 2

Learning: 2026-10-17T19:14:43.945Z

Learnt from: CR
Repo: BenCodez/VotifierPlus PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-10-17T19:14:43.945Z
Learning: Source excerpt:
# Maintainer and AI-agent guide

## Network and protocol invariants

12. Shutdown must terminate listener and connection workers within a bound and prevent callbacks after disable.

Applied to files:

  • VotifierPlus/src/main/java/com/vexsoftware/votifier/net/VoteForwarder.java
Learning: 2026-10-17T19:14:43.945Z

Learnt from: CR
Repo: BenCodez/VotifierPlus PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-10-17T19:14:43.945Z
Learning: Source excerpt:
# Maintainer and AI-agent guide

## Test package organization

Put Java test classes and reusable test helpers under `com.bencodez.votifierplus.tests`, using subpackages for related areas. Match the directories below `src/test/java` to the declared package. Keep new and moved tests in this namespace and update imports, resource lookups, reflection references, and build selectors when relocating them.

Applied to files:

  • VotifierPlus/src/test/java/com/bencodez/votifierplus/tests/net/VoteForwarderRetryTest.java
ast-grep (0.51.3)

VotifierPlus/src/main/java/com/vexsoftware/votifier/net/VoteForwarder.java

[warning] 234-234: Regular expression is compiled from a non-literal, possibly user-controlled value. A crafted regex (or input matched against one) can trigger catastrophic backtracking and hang the thread (ReDoS). Use a hardcoded literal pattern, wrap untrusted text with Pattern.quote(...), or validate/length-limit the input and enforce a matching timeout before passing it to Pattern.compile / String.matches / String.replaceAll / String.replaceFirst.
Context: retry.matches(server)
Note: [CWE-1333] Inefficient Regular Expression Complexity.

(redos-non-literal-regex-java)

VotifierPlus/src/test/java/com/bencodez/votifierplus/tests/net/VoteForwarderHandshakeTest.java

[warning] 743-743: Avoid user-generated class names for reflection
Context: Class.forName(VoteForwarder.class.getName() + "$Origin")
Note: [CWE-470] Use of Externally-Controlled Input to Select Classes or Code ('Unsafe Reflection').

(unsafe-reflection-java)

VotifierPlus/src/test/java/com/bencodez/votifierplus/tests/net/VoteForwarderRetryTest.java

[info] 282-337: "Detected use of a Java socket that is not encrypted. As a result, the
traffic could be read by an attacker intercepting the network traffic. Use
an SSLSocket created by 'SSLSocketFactory' or 'SSLServerSocketFactory'
instead."
Context: new Socket() {
@Override
public void connect(SocketAddress address, int timeout) throws IOException {
int port = ((InetSocketAddress) address).getPort();
connects.add(port);
if (port == unavailablePort) {
throw new ConnectException();
}
}

			@Override
			public ByteArrayInputStream getInputStream() {
				return new ByteArrayInputStream((greeting + "\n").getBytes(StandardCharsets.UTF_8));
			}

			@Override
			public synchronized void close() throws IOException {
				super.close();
				if (blockWrite) {
					retrySocketClosed.countDown();
				}
			}

			@Override
			public OutputStream getOutputStream() {
				return new OutputStream() {
					@Override
					public void write(byte[] bytes) throws IOException {
						writeCalls++;
						if (blockWrite) {
							writeStarted.countDown();
							try {
								if (!retrySocketClosed.await(4, TimeUnit.SECONDS)) {
									throw new AssertionError("Retry socket was not closed during retirement");
								}
							} catch (InterruptedException ex) {
								Thread.currentThread().interrupt();
								throw new AssertionError(ex);
							}
							throw new IOException("Socket closed");
						}
						if (failWrite) {
							throw new IOException();
						}
						var payload = new ByteArrayOutputStream();
						payload.write(bytes);
						payloads.add(payload);
					}

					@Override
					public void write(int value) {
						throw new AssertionError("Expected a whole payload");
					}
				};
			}
		}

Note: [CWE-319] Cleartext Transmission of Sensitive Information

(unencrypted-socket-java)

Additional comments: 1

VotifierPlus/src/main/java/com/vexsoftware/votifier/net/VoteForwarder.java: 1

215-217: Data Integrity & Integration

The comment's capacity-violation claim is not supported. Retry admission and slot release both run under lifecycleLock. Admission also checks the shutdown state before it reads pendingRetries. Before retirement, the count equals the reserved slots and cannot exceed retryCapacity. The drained queue is subtracted exactly once, and a task that runs releases its slot exactly once in runRetry's finally block.

The only remaining divergence is the model's Discard case. A dequeued wrapper that never enters runRetry could leave pendingRetries stale. That can happen only after retirement. The count is private, and admission is already blocked there. No observable capacity, retry, or data consequence follows, so this does not establish a material defect.

@BenCodez
BenCodez marked this pull request as ready for review November 25, 2026 01:48
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-25T01:50:26.394952Z b763d9f Draft marked ready
🔒 Security Review ✅ Completed 2026-11-25T01:51:58.668480Z b763d9f Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@BenCodez
BenCodez merged commit dc1848f into master Nov 25, 2026
3 checks passed
@BenCodez
BenCodez deleted the cez/a3eaa45e branch November 25, 2026 01:53
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.

1 participant