@@ -82,48 +82,36 @@ type XAResourceManager struct {
82
82
}
83
83
84
84
func (xaManager * XAResourceManager ) xaTwoPhaseTimeoutChecker () {
85
- var dbResource * DBResource
86
- xaManager .resourceCache .Range (func (key , value any ) bool {
87
- if source , ok := value .(* DBResource ); ok {
88
- dbResource = source
89
- }
90
- return false
91
- })
92
-
93
- if dbResource .IsShouldBeHeld () {
94
- ticker := time .NewTicker (time .Second )
95
- for {
96
- select {
97
- case <- ticker .C :
98
- xaManager .resourceCache .Range (func (key , value any ) bool {
99
- source , ok := value .(* DBResource )
100
- if ! ok {
101
- return true
102
- }
103
- if source .IsShouldBeHeld () {
85
+ ticker := time .NewTicker (time .Second )
86
+ for {
87
+ select {
88
+ case <- ticker .C :
89
+ xaManager .resourceCache .Range (func (key , value any ) bool {
90
+ source , ok := value .(* DBResource )
91
+ if ! ok {
92
+ return true
93
+ }
94
+ if source .IsShouldBeHeld () {
95
+ return true
96
+ }
97
+
98
+ source .GetKeeper ().Range (func (key , value any ) bool {
99
+ connectionXA , isConnectionXA := value .(* XAConn )
100
+ if ! isConnectionXA {
104
101
return true
105
102
}
106
103
107
- source .GetKeeper ().Range (func (key , value any ) bool {
108
- connectionXA , isConnectionXA := value .(* XAConn )
109
- if ! isConnectionXA {
110
- return true
104
+ if time .Now ().Sub (connectionXA .prepareTime ) > xaManager .config .TwoPhaseHoldTime {
105
+ if err := connectionXA .CloseForce (); err != nil {
106
+ log .Errorf ("Force close the xa xid:%s physical connection fail" , connectionXA .txCtx .XID )
111
107
}
112
-
113
- if time .Now ().Sub (connectionXA .prepareTime ) > xaManager .config .TwoPhaseHoldTime {
114
- if err := connectionXA .CloseForce (); err != nil {
115
- log .Errorf ("Force close the xa xid:%s physical connection fail" , connectionXA .txCtx .XID )
116
- }
117
- }
118
- return true
119
- })
108
+ }
120
109
return true
121
110
})
122
- }
111
+ return true
112
+ })
123
113
}
124
-
125
114
}
126
-
127
115
}
128
116
129
117
func (xaManager * XAResourceManager ) GetBranchType () branch.BranchType {
0 commit comments