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

xds: Assert XdsNR's cluster ref counting is consistent #11943

Merged
merged 1 commit into from
Mar 19, 2025
Merged
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
18 changes: 11 additions & 7 deletions xds/src/main/java/io/grpc/xds/XdsNameResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -537,17 +537,21 @@

private void releaseCluster(final String cluster) {
int count = clusterRefs.get(cluster).refCount.decrementAndGet();
if (count < 0) {
throw new AssertionError();

Check warning on line 541 in xds/src/main/java/io/grpc/xds/XdsNameResolver.java

View check run for this annotation

Codecov / codecov/patch

xds/src/main/java/io/grpc/xds/XdsNameResolver.java#L541

Added line #L541 was not covered by tests
}
if (count == 0) {
syncContext.execute(new Runnable() {
@Override
public void run() {
if (clusterRefs.get(cluster).refCount.get() == 0) {
clusterRefs.remove(cluster);
if (resolveState.lastConfigOrStatus.hasValue()) {
updateResolutionResult(resolveState.lastConfigOrStatus.getValue());
} else {
resolveState.cleanUpRoutes(resolveState.lastConfigOrStatus.getStatus());
}
if (clusterRefs.get(cluster).refCount.get() != 0) {
throw new AssertionError();

Check warning on line 548 in xds/src/main/java/io/grpc/xds/XdsNameResolver.java

View check run for this annotation

Codecov / codecov/patch

xds/src/main/java/io/grpc/xds/XdsNameResolver.java#L548

Added line #L548 was not covered by tests
}
clusterRefs.remove(cluster);
if (resolveState.lastConfigOrStatus.hasValue()) {
updateResolutionResult(resolveState.lastConfigOrStatus.getValue());
} else {
resolveState.cleanUpRoutes(resolveState.lastConfigOrStatus.getStatus());

Check warning on line 554 in xds/src/main/java/io/grpc/xds/XdsNameResolver.java

View check run for this annotation

Codecov / codecov/patch

xds/src/main/java/io/grpc/xds/XdsNameResolver.java#L554

Added line #L554 was not covered by tests
}
}
});
Expand Down