Skip to content

HDDS-16335. Change XceiverClientShortCircuit to support concurrent access - #11225

Open
echonesis wants to merge 2 commits into
apache:masterfrom
echonesis:test-HDDS-16335
Open

HDDS-16335. Change XceiverClientShortCircuit to support concurrent access#11225
echonesis wants to merge 2 commits into
apache:masterfrom
echonesis:test-HDDS-16335

Conversation

@echonesis

@echonesis echonesis commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

XceiverClientShortCircuit did not consistently synchronize access to its connection state and other non-final fields.

This pull request uses the existing lock to protect all non-final fields and serialize connection setup, request registration and writes, and close transitions. Blocking reads, response waits, and receiver joins remain outside the lock.

Thread-safe final fields are used for response and timeout processing so they can proceed while a socket write is blocked. The client also remains one-shot: repeated connect() calls are allowed while open, but reconnecting after failure or close is rejected.

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-16335

How was this patch tested?

Local Test

mvn -pl :ozone-integration-test -am test \
  -Dtest=TestXceiverClientManagerSC \
  -Dsurefire.failIfNoSpecifiedTests=false \
  -DskipShade -DskipRecon -DskipDocs

GitHub Actions CI: https://github.com/echonesis/ozone/actions/runs/34445616895

Generated-by: Codex (GPT-5)

@echonesis echonesis changed the title HDDS-16335. Change XceiverClientShortCircuit to support concurrent ac… HDDS-16335. Change XceiverClientShortCircuit to support concurrent access Sep 9, 2026
@echonesis
echonesis marked this pull request as draft September 10, 2026 01:51
@echonesis
echonesis marked this pull request as ready for review September 10, 2026 10:08

@Gargi-jais11 Gargi-jais11 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @echonesis for working on the PR. Left few review comemnts

Comment on lines +478 to 484
if (failure != null) {
LOG.error("Failed to send command {}", request, failure);
for (RequestEntry requestEntry : pending) {
requestEntry.fail(failure);
}
metrics.decrPendingContainerOpsMetrics(request.getCmdType());
metrics.addContainerOpsLatency(request.getCmdType(), System.nanoTime() - entry.getCreateTimeNs());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In sendRequest(), when the write faills we are currently fail all entries in pending, but metrics.decrPendingContainerOpsMetrics() and addContainerOpsLatency() are only called once for the current request, so other in-flight requests will leave infleted pending metrics.

readDaemon.join();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
pending.forEach(entry -> entry.fail(new ClosedChannelException()));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

here when the close fails, we are not tracking any metrics failures.

lock.unlock();
}
if (entry != null) {
entry.getFuture().completeExceptionally(e);

@Gargi-jais11 Gargi-jais11 Sep 11, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In the generic catch (Throwable e) block,
if entry != null you are calling the entry.getFuture().completeExceptionally(e) and then pending.forEach(i -> i.fail(e)). If entry is still in sentRequests, it gets failed twice. CompletableFuture ignores the second completion, so this is harmless but redundant.

}
readDaemon.interrupt();
}
pending = new ArrayList<>(sentRequests.values());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: After failing pending requests on close, consider clearing sentRequests under the lock.
Similarly in sendRequests and recieveResponseTask

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.

2 participants