You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by yi...@apache.org on 2025/09/06 12:37:20 UTC
(dubbo-go) branch fix/rpc_status_cas created (now 3e6a42004)
This is an automated email from the ASF dual-hosted git repository.
yizhenqiang pushed a change to branch fix/rpc_status_cas
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git
at 3e6a42004 bugfix: Ensure that rpcStatus.maxElapsed, rpcStatus.succeededMaxElapsed, and rpcStatus.failedMaxElapsed are correctly replaced through cas.
This branch includes the following new commits:
new 3e6a42004 bugfix: Ensure that rpcStatus.maxElapsed, rpcStatus.succeededMaxElapsed, and rpcStatus.failedMaxElapsed are correctly replaced through cas.
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(dubbo-go) 01/01: bugfix: Ensure that rpcStatus.maxElapsed, rpcStatus.succeededMaxElapsed, and rpcStatus.failedMaxElapsed are correctly replaced through cas.
Posted by yi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
yizhenqiang pushed a commit to branch fix/rpc_status_cas
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git
commit 3e6a420041dd3afc4b48c5e738e834fc0d2846d2
Author: yizhenqiang <yi...@apache.org>
AuthorDate: Sat Sep 6 20:37:02 2025 +0800
bugfix: Ensure that rpcStatus.maxElapsed, rpcStatus.succeededMaxElapsed, and rpcStatus.failedMaxElapsed are correctly replaced through cas.
Fixes: #3006
Signed-off-by: yizhenqiang <yi...@apache.org>
---
protocol/base/rpc_status.go | 33 +++++++++++++++++++++++++++------
1 file changed, 27 insertions(+), 6 deletions(-)
diff --git a/protocol/base/rpc_status.go b/protocol/base/rpc_status.go
index 470c1eee5..e9196c32a 100644
--- a/protocol/base/rpc_status.go
+++ b/protocol/base/rpc_status.go
@@ -159,21 +159,42 @@ func endCount0(rpcStatus *RPCStatus, elapsed int64, succeeded bool) {
atomic.AddInt32(&rpcStatus.total, 1)
atomic.AddInt64(&rpcStatus.totalElapsed, elapsed)
- if rpcStatus.maxElapsed < elapsed {
- atomic.StoreInt64(&rpcStatus.maxElapsed, elapsed)
+ for {
+ oldValue := atomic.LoadInt64(&rpcStatus.maxElapsed)
+ if oldValue >= elapsed {
+ break
+ }
+ if atomic.CompareAndSwapInt64(&rpcStatus.maxElapsed, oldValue, elapsed) {
+ break
+ }
}
+
if succeeded {
- if rpcStatus.succeededMaxElapsed < elapsed {
- atomic.StoreInt64(&rpcStatus.succeededMaxElapsed, elapsed)
+ for {
+ oldValue := atomic.LoadInt64(&rpcStatus.succeededMaxElapsed)
+ if oldValue >= elapsed {
+ break
+ }
+ if atomic.CompareAndSwapInt64(&rpcStatus.succeededMaxElapsed, oldValue, elapsed) {
+ break
+ }
}
+
atomic.StoreInt32(&rpcStatus.successiveRequestFailureCount, 0)
} else {
atomic.StoreInt64(&rpcStatus.lastRequestFailedTimestamp, CurrentTimeMillis())
atomic.AddInt32(&rpcStatus.successiveRequestFailureCount, 1)
atomic.AddInt32(&rpcStatus.failed, 1)
atomic.AddInt64(&rpcStatus.failedElapsed, elapsed)
- if rpcStatus.failedMaxElapsed < elapsed {
- atomic.StoreInt64(&rpcStatus.failedMaxElapsed, elapsed)
+
+ for {
+ oldValue := atomic.LoadInt64(&rpcStatus.failedMaxElapsed)
+ if oldValue >= elapsed {
+ break
+ }
+ if atomic.CompareAndSwapInt64(&rpcStatus.failedMaxElapsed, oldValue, elapsed) {
+ break
+ }
}
}
}