Skip to content

Feature/fix triple nonblocking stream close#3465

Closed
Vanillaxi wants to merge 6 commits into
apache:mainfrom
Vanillaxi:feature/fix-triple-nonblocking-stream-close
Closed

Feature/fix triple nonblocking stream close#3465
Vanillaxi wants to merge 6 commits into
apache:mainfrom
Vanillaxi:feature/fix-triple-nonblocking-stream-close

Conversation

@Vanillaxi

Copy link
Copy Markdown
Contributor

What

  • Change duplexHTTPCall.CloseRead() to close the response body directly instead of draining the remaining response body first.
  • Add regression tests for non-blocking close behavior across server-stream, bidi-stream, client-stream, and duplexHTTPCall.

Why

CloseRead() previously drained the remaining response body before closing it. If the server kept the response stream open, returned an error early, stopped reading the request side, or the transport stopped producing response bytes, client close paths such as ServerStreamForClient.Close, BidiStreamForClient.CloseResponse, and ClientStreamForClient.CloseAndReceive could block unnecessarily.

This selectively ports only the stream close lifecycle behavior from the connect-go v1.18.0 fix without bringing in unrelated connect-go features.

Fixes #3457

Tests

go test ./protocol/triple/triple_protocol -run 'TestServerStreamCloseDoesNotDrainResponse|TestBidiStreamCloseResponseDoesNotDrainResponse|TestBidiStreamCloseResponseAfterServerStopsReading|TestClientStreamCloseAndReceiveAfterServerReturnsError|TestDuplexHTTPCallCloseReadDoesNotDrainResponseBody' -count=1
go test ./protocol/triple/triple_protocol
go test ./protocol/triple

Alanxtl and others added 6 commits June 25, 2026 16:52
… state (apache#3353) (apache#3367)

* feat(metadata): add internal RWMutex for MetadataInfo and fix json serialization (apache#3353)

Add sync.RWMutex to MetadataInfo struct with json:"-" / hessian:"-"
tags to skip serialization. All mutating methods (AddService, RemoveService,
AddSubscribeURL, RemoveSubscribeURL) acquire the write lock, and read
methods (GetExportedServiceURLs, GetSubscribedURLs, GetServices) acquire
the read lock. The new GetServices method returns a snapshot copy.

Signed-off-by: jieguo-coder <1193249232@qq.com>

* feat(metadata): add lock protection for global registry and instances (apache#3353)

Add sync.RWMutex to protect registryMetadataInfo in metadata.go and
instances in report_instance.go. Extract getMetadataReportUnsafe helper
to avoid reentrant RLock deadlock in GetMetadataReportByRegistry fallback.
Fix nacos report_test to use pointer to MetadataInfo for json.Marshal.

Signed-off-by: jieguo-coder <1193249232@qq.com>

* feat(metadata): fix concurrency safety in listener callbacks and external calls (apache#3353)

Add mutex locking to AddListenerAndNotify and RemoveListener to protect
shared fields listeners and serviceUrls. Replace direct access to
MetadataInfo.Services with safe GetServices method in OnEvent and
convertV2 to prevent unprotected map reads.

Signed-off-by: jieguo-coder <1193249232@qq.com>

* style: format import blocks using dubbo-go imports-formatter

Signed-off-by: jieguo-coder <1193249232@qq.com>

* style: format metadata.go and report_instance.go to pass CI

Signed-off-by: jieguo-coder <1193249232@qq.com>

* fix(metadata): resolve data races pointed out in code review

Signed-off-by: jieguo-coder <1193249232@qq.com>

* test: fix failing tests and improve unit test coverage

Signed-off-by: jieguo-coder <1193249232@qq.com>

* test: fix testifylint error by avoiding require in goroutines

Signed-off-by: jieguo-coder <1193249232@qq.com>

* fix(metadata): deep copy ServiceInfo to prevent write-on-read data race and reduce lock granularity in report creation

Signed-off-by: jieguo-coder <1193249232@qq.com>

* chore: trigger CI re-run for codecov gpg issue

* refactor(metadata): implement no-lock helper to fix data race and avoid deadlocks in ReplaceExportedServices

Signed-off-by: jieguo-coder <1193249232@qq.com>

* test: fix compilation error in instance changed listener tests by adding missing registryId argument

Signed-off-by: jieguo-coder <1193249232@qq.com>

* fix(metadata): add RLock around global map lookup in RemoveService and RemoveSubscribeURL to prevent concurrent map read/write

Signed-off-by: jieguo-coder <1193249232@qq.com>

---------

Signed-off-by: jieguo-coder <1193249232@qq.com>
…e#3371)

* feat(metadata): add renew and GC policy for app-level metadata

* fix ci

* fix ci

* fix review

* fix nil

* rebase develop, resolve conflicts, add units
…ache#3462)

Investigate whether connect-go v1.19.2's fix for the concurrent Send +
CloseAndReceive nil-pointer dereference (connectrpc/connect-go#919) applies
to Dubbo-go's forked Triple runtime.

duplexHTTPCall is not affected: newDuplexHTTPCall allocates the request-body
io.Pipe at construction and never reassigns requestBodyWriter, so it is always
non-nil and concurrent Write/CloseWrite are safe in any order. The upstream
race, where the pipe was created lazily on the first Send and a racing
CloseWrite could leave it nil, is structurally impossible here, so no
synchronization change is ported.

- add TestDuplexHTTPCallConcurrentWriteAndCloseWrite and
  TestDuplexHTTPCallConcurrentWriteCloseRace as regression guards (run under
  -race) that pin the construction-time pipe invariant
- document the invariant on requestBodyWriter to keep the allocation out of a
  lazy/first-send path

Ref: apache#3458
…F header (apache#3464)

* fix(triple_protocol): replace Buf Technologies license header with ASF header

- Replace Buf Technologies copyright header with Apache Software Foundation header in 55 Go files
- Replace Buf Technologies copyright header in 4 proto files
- Remove license-header tool from Makefile to prevent auto-generation of Buf headers
- Remove COPYRIGHT_YEARS and LICENSE_IGNORE variables from Makefile

This ensures all files have proper ASF license headers for Apache Dubbo project.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix(triple_protocol): restore build constraints in maxbytes.go

- Add //go:build go1.19 and // +build go1.19 constraints
- Build constraints must precede license header per Go convention
- Remove duplicate leftover license text lines

Co-Authored-By: Claude <noreply@anthropic.com>

* fix(triple_protocol): restore missing package declaration in triple_ext_test.go

The package declaration was accidentally removed when replacing the license header.

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@Vanillaxi Vanillaxi closed this Jun 30, 2026
@codecov-commenter

codecov-commenter commented Jun 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 71.70418% with 88 lines in your changes missing coverage. Please review.
✅ Project coverage is 53.91%. Comparing base (8b5bbcf) to head (9da32ff).

Files with missing lines Patch % Lines
...try/servicediscovery/service_discovery_registry.go 64.15% 27 Missing and 11 partials ⚠️
metadata/info/metadata_info.go 70.58% 15 Missing ⚠️
metadata/report/zookeeper/report.go 62.85% 12 Missing and 1 partial ⚠️
metadata/report/nacos/report.go 80.85% 7 Missing and 2 partials ⚠️
metadata/report/etcd/report.go 76.00% 6 Missing ⚠️
metadata/report/report.go 0.00% 5 Missing ⚠️
metadata/report_instance.go 87.50% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3465      +/-   ##
==========================================
+ Coverage   53.57%   53.91%   +0.34%     
==========================================
  Files         460      461       +1     
  Lines       35182    35476     +294     
==========================================
+ Hits        18847    19127     +280     
+ Misses      14857    14844      -13     
- Partials     1478     1505      +27     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

Evaluate non-blocking stream client close behavior in Triple runtime

7 participants