Skip to content

fix(store): bind each gRPC stub to its own channel - #3128

Merged
imbajin merged 1 commit into
apache:masterfrom
bitflicker64:fix/hstore-grpc-stub-channel-3125
Jul 31, 2026
Merged

fix(store): bind each gRPC stub to its own channel#3128
imbajin merged 1 commit into
apache:masterfrom
bitflicker64:fix/hstore-grpc-stub-channel-3125

Conversation

@bitflicker64

Copy link
Copy Markdown
Contributor

Purpose of the PR

AbstractGrpcClient creates 32 managed channels per target, but both
stub-pool initialization loops bound every entry to one channel selected
before the loop. Traffic was concentrated on a single connection while the
other 31 channels remained idle.

Main Changes

  • Bind each blocking-stub pool entry to the channel at the same pool index.
  • Bind each asynchronous-stub pool entry to the channel at the same pool index.
  • Add self-contained tests with fake channels and stubs that verify both pools
    cover every channel without a running PD or Store cluster.
  • Add ClientSuiteTest so the existing store-client-test profile runs the
    new coverage without including cluster-dependent client tests.

Verifying these changes

  • Need tests and can be verified as follows:
    • On the original indexing, both tests fail with 32 channels expected and 1 used.
    • mvn install -pl hugegraph-struct -am -DskipTests: passed.
    • mvn test -pl hugegraph-store/hg-store-test -am -P store-client-test: 2 passed, 0 failed.
    • mvn editorconfig:format: no files changed.
    • mvn clean compile -Dmaven.javadoc.skip=true: passed on Java 11.

Does this PR potentially affect the following parts?

  • Dependencies
  • Modify configurations
  • The public API
  • Other affects
  • Nope

Documentation Status

  • Doc - TODO
  • Doc - Done
  • Doc - No Need

AbstractGrpcClient opens concurrency (32) ManagedChannels per target, but
both stub-pool initializers used one precomputed channel index inside their
loops. Every pool entry therefore pointed at the same channel while the other
31 channels remained idle.

- use channels[i] in the blocking and async pool initializers
- add self-contained tests that verify every pool channel is bound
- add ClientSuiteTest so the store-client-test profile runs the tests

Fixes apache#3125
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working store Store module tests Add or improve test cases labels Jul 29, 2026
@imbajin
imbajin requested a review from Copilot July 30, 2026 07:54

Copilot AI 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.

Pull request overview

This PR fixes a channel-indexing bug in AbstractGrpcClient where both blocking and async stub pools were unintentionally binding all entries to a single ManagedChannel, preventing the intended distribution across the per-target channel pool. It also adds targeted unit tests (run via the existing store-client-test surefire execution) to ensure each stub-pool entry is bound to its corresponding channel.

Changes:

  • Fix stub-pool initialization to bind value[i] to channels[i] for both blocking and async stubs.
  • Add unit tests with fake channels/stubs to verify both pools cover all created channels without requiring a running cluster.
  • Add a ClientSuiteTest suite to ensure store-client-test runs the new coverage while excluding cluster-dependent client tests.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
hugegraph-store/hg-store-client/src/main/java/org/apache/hugegraph/store/client/grpc/AbstractGrpcClient.java Corrects stub-pool initialization so each stub is paired with its corresponding channel index.
hugegraph-store/hg-store-test/src/main/java/org/apache/hugegraph/store/client/grpc/AbstractGrpcClientTest.java Adds unit tests to assert blocking/async stub pools span all channels using local fakes.
hugegraph-store/hg-store-test/src/main/java/org/apache/hugegraph/store/client/ClientSuiteTest.java Adds the store-client-test suite entry point to run only cluster-independent client tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +187 to +192
@Override
public boolean awaitTermination(long timeout, TimeUnit unit) {
return this.shutdown;
}
}
}

@bitflicker64 bitflicker64 Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@copilot These methods are concrete in gRPC 1.39.0, not abstract. FakeManagedChannel implements all required abstract methods, and both the Java 11 store-client-test profile and the Store CI compile and pass. No additional overrides are required.

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jul 31, 2026
@github-project-automation github-project-automation Bot moved this from In progress to In review in HugeGraph PD-Store Tasks Jul 31, 2026
@imbajin
imbajin merged commit b026a90 into apache:master Jul 31, 2026
16 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in HugeGraph PD-Store Tasks Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files. store Store module tests Add or improve test cases

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Bug][HStore Client] gRPC stub pools bind every entry to one ManagedChannel

3 participants