starocean999 opened a new pull request, #65409:
URL: https://github.com/apache/doris/pull/65409

   
   ### What problem does this PR solve?
   RefreshDatabaseCommand.run() [line 43]
   -> RefreshManager.handleRefreshDb() [line 80]
   -> refreshDbInternal() [line 120]
   -> ExternalDatabase.resetMetaToUninitialized() [line 119]
   -> synchronized(this) { [line 126]
   metaCache.invalidateAll() [line 132]
   -> namesCache.invalidateAll() [MetaCache:148]
   -> metaObjCache.invalidateAll() [MetaCache:151]
   
   RefreshTableCommand.run() [line 43]
   -> RefreshManager.handleRefreshTable() [line 124]
   -> ExternalDatabase.getTableNullable() [line 499]
   -> makeSureInitialized() [line 500]
   -> MetaCache.getMetaObj() [line 505]
   -> synchronized(metaObjCache) { [MetaCache:93]
   metaObjCache.get(name) // Caffeine node lock [MetaCache:99]
   -> [cache loader from buildMetaCache()] [line 174]
   -> buildTableForInit() [line 260]
   -> getTableNamesWithLock() [line 271]
   -> makeSureInitialized() [line 497]
   -> synchronized(this) // DEADLOCK [line 141]
   
   Problem Summary:
   
   `ExternalDatabase.resetMetaToUninitialized()` calls
   `metaCache.invalidateAll()` while holding `synchronized(this)`. This is
   unnecessary — `MetaCache.invalidateAll()` only touches thread-safe Caffeine
   caches and a `ConcurrentHashMap`, none of which require the 
`ExternalDatabase`
   monitor for correctness. The reference pattern 
`ExternalCatalog.resetToUninitialized()`
   already calls `onRefreshCache()` (which calls `invalidateAll()`) *outside*
   `synchronized(this)`.
   
   None
   
   ### Check List (For Author)
   
   - Test <!-- At least one of them must be included. -->
       - [ ] Regression test
       - [ ] Unit Test
       - [ ] Manual test (add detailed scripts or steps below)
       - [ ] No need to test or manual test. Explain why:
           - [ ] This is a refactor/code format and no logic has been changed.
           - [ ] Previous test can cover this change.
           - [ ] No code files have been changed.
           - [ ] Other reason <!-- Add your reason?  -->
   
   - Behavior changed:
       - [ ] No.
       - [ ] Yes. <!-- Explain the behavior change -->
   
   - Does this need documentation?
       - [ ] No.
       - [ ] Yes. <!-- Add document PR link here. eg: 
https://github.com/apache/doris-website/pull/1214 -->
   
   ### Check List (For Reviewer who merge this PR)
   
   - [ ] Confirm the release note
   - [ ] Confirm test cases
   - [ ] Confirm document
   - [ ] Add branch pick label <!-- Add branch pick label that this PR should 
merge into -->
   
   


-- 
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