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

   ## What problem does this PR solve?
   
   Issue Number: close #xxx
   
   Problem Summary:
   
   `CatalogRecycleBin.runAfterCatalogReady()` captures 
`System.currentTimeMillis()` once at the beginning of the method and shares 
this timestamp across `erasePartition()`, `eraseTable()`, and 
`eraseDatabase()`. Since each erase operation can take significant time (I/O, 
log writes, lock acquisition), the later methods use a stale timestamp for 
expiration checks, causing delayed cleanup of tables and databases.
   
   For example, if `erasePartition` takes 5 minutes, `eraseTable` and 
`eraseDatabase` will use a timestamp that is 5 minutes old, potentially 
skipping items that became eligible for cleanup during that period.
   
   ### Fix
   
   Each erase method now gets its own fresh `System.currentTimeMillis()` call, 
ensuring accurate expiration checks.
   
   **Before:**
   ```java
   long currentTimeMs = System.currentTimeMillis();
   erasePartition(currentTimeMs);
   eraseTable(currentTimeMs);
   eraseDatabase(currentTimeMs);
   ```
   
   **After:**
   ```java
   erasePartition(System.currentTimeMillis());
   eraseTable(System.currentTimeMillis());
   eraseDatabase(System.currentTimeMillis());
   ```
   
   ## Release note
   
   Fix delayed cleanup of tables and databases in CatalogRecycleBin when 
partition erasure takes significant time
   
   ## Check List (For Author)
   
   - Test: Unit Test
       - Added `testEraseUsesFreshCurrentTime` in `CatalogRecycleBinTest` that 
creates a table with 1000 partitions, force-drops them, and verifies that 
tables and databases with expired recycle times are properly cleaned up even 
when partition erasure takes time
   - Behavior changed: No (only fixes timing accuracy, no API or config changes)
   - Does this need documentation: No


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