@@ -19,6 +19,8 @@ import (
1919 // "github.com/twmb/murmur3"
2020 "golang.org/x/exp/maps"
2121
22+ "github.com/redis/go-redis/v9"
23+
2224 "github.com/urnetwork/glog"
2325
2426 "github.com/urnetwork/server"
@@ -1321,33 +1323,49 @@ func ClientError(ctx context.Context, networkId server.Id, clientId server.Id, c
13211323
13221324 server .Redis (ctx , func (r server.RedisClient ) {
13231325
1324- networkCount , err := r .Incr (ctx , networkKey ).Result ()
1326+ var networkCountCmd * redis.IntCmd
1327+ var clientCountCmd * redis.IntCmd
1328+ var networkErrorMessageCountCmd * redis.IntCmd
1329+ var clientErrorMessageCountCmd * redis.IntCmd
1330+ r .TxPipelined (ctx , func (pipe redis.Pipeliner ) error {
1331+ networkCountCmd = pipe .Incr (ctx , networkKey )
1332+ pipe .Expire (ctx , networkKey , ttl )
1333+
1334+ clientCountCmd = pipe .Incr (ctx , clientKey )
1335+ pipe .Expire (ctx , clientKey , ttl )
1336+
1337+ networkErrorMessageCountCmd = pipe .Incr (ctx , networkErrorMessageKey )
1338+ pipe .Expire (ctx , networkErrorMessageKey , ttl )
1339+
1340+ clientErrorMessageCountCmd = pipe .Incr (ctx , clientErrorMessageKey )
1341+ pipe .Expire (ctx , clientErrorMessageKey , ttl )
1342+
1343+ return nil
1344+ })
1345+
1346+ networkCount , err := networkCountCmd .Result ()
13251347 if err == nil {
1326- r .Expire (ctx , networkKey , ttl )
13271348 if networkCount % warnThreshold == 0 {
13281349 glog .V (1 ).Infof ("[ncm][%s]network has a significant amount of connection errors (%d)\n " , networkId , networkCount )
13291350 }
13301351 }
13311352
1332- clientCount , err := r . Incr ( ctx , clientKey ) .Result ()
1353+ clientCount , err := clientCountCmd .Result ()
13331354 if err == nil {
1334- r .Expire (ctx , clientKey , ttl )
13351355 if clientCount % warnThreshold == 0 {
13361356 glog .V (1 ).Infof ("[ncm][%s]client has a significant amount of connection errors (%d)\n " , clientId , clientCount )
13371357 }
13381358 }
13391359
1340- networkErrorMessageCount , err := r . Incr ( ctx , networkErrorMessageKey ) .Result ()
1360+ networkErrorMessageCount , err := networkErrorMessageCountCmd .Result ()
13411361 if err == nil {
1342- r .Expire (ctx , networkErrorMessageKey , ttl )
13431362 if networkErrorMessageCount % warnThreshold == 0 {
13441363 glog .V (1 ).Infof ("[ncm][%s]network has a significant count of connection error message (%d): %s\n " , networkId , networkErrorMessageCount , errorMessage )
13451364 }
13461365 }
13471366
1348- clientErrorMessageCount , err := r . Incr ( ctx , clientErrorMessageKey ) .Result ()
1367+ clientErrorMessageCount , err := clientErrorMessageCountCmd .Result ()
13491368 if err == nil {
1350- r .Expire (ctx , clientErrorMessageKey , ttl )
13511369 if clientErrorMessageCount % warnThreshold == 0 {
13521370 glog .V (1 ).Infof ("[ncm][%s]client has a significant count of connection error message (%d): %s\n " , clientId , clientErrorMessageCount , errorMessage )
13531371 }
0 commit comments