AlexStocks commented on code in PR #1085:
URL: 
https://github.com/apache/incubator-seata-go/pull/1085#discussion_r3004326701


##########
pkg/rm/tcc/fence/handler/tcc_fence_wrapper_handler.go:
##########
@@ -290,3 +301,58 @@ func (handler *tccFenceWrapperHandler) 
traversalCleanChannel(db *sql.DB) {
                }
        }
 }
+
+func (handler *tccFenceWrapperHandler) drainCacheTask() {
+       ticker := time.NewTicker(cleanInterval)
+       defer ticker.Stop()
+
+       for {
+               select {
+               case <-ticker.C:
+                       handler.cacheMutex.Lock()
+
+                       if handler.logCache.Len() == 0 {
+                               handler.cacheMutex.Unlock()
+                               continue
+                       }
+
+                       handler.dbMutex.RLock()
+                       db := handler.db
+                       handler.dbMutex.RUnlock()
+                       if db == nil {
+                               handler.cacheMutex.Unlock()
+                               continue
+                       }
+
+                       var batch []model.FenceLogIdentity

Review Comment:
   [P1] 这里先把所有元素从 logCache 移除,再去 Begin/Delete。只要 db.Begin() 或 
deleteBatchFence() 失败,这批 identity 就已经从缓存里丢掉了,后面也不会重试,等于把这次修复要解决的 queue 
满时兜底清理重新变成了静默漏删。另外失败分支也没有 Rollback,事务会一直占着连接。建议只在删除成功并提交后再移出 cache,或者失败时把 batch 
放回 cache,并在所有失败分支显式回滚。



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to