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

   ### Background
   
   DROP DATABASE retains recoverable metadata in the catalog recycle bin. 
RECOVER DATABASE restores its tables and publishes the database in the internal 
catalog.
   
   ### What problem does this PR solve?
   
   Issue Number: None
   Related PR: None
   PR Type: Bugfix
   
   Problem Summary:
   
   RECOVER DATABASE removed recycled metadata before attempting to acquire the 
catalog lock. A lock timeout left the database absent from both the active 
catalog and the recycle bin, so subsequent queries and recovery attempts 
failed. Acquire the catalog lock and validate the target name before restoring 
recycled metadata.
   
   ### Details
   
   - **Frequency:** Triggered when RECOVER DATABASE times out waiting for a 
catalog lock held by another DDL operation.
   - **Root cause:** Recovery consumed the recycle-bin entry before 
catalog-lock acquisition could fail.
   - **Why existing tests missed it:** Existing recovery tests did not exercise 
catalog-lock contention during database recovery.
   - **Fix:** Hold the existing catalog lock across name validation and 
metadata recovery, and release it from an outer finally block.
   - **Other paths and branches:** Unknown-database failures release the 
catalog lock. Recovery with a new database name follows the same protected path.
   
   ### Testing
   
   - Added a regression test using real catalog and recycle-bin objects with a 
competing thread holding the catalog lock. It fails before the fix because the 
recycled database has disappeared, and passes after the fix.
   - Ran RecoverDatabaseLockTest, DropDbTest, RecoverTest and 
CatalogRecycleBinTest through run-fe-ut.sh: 38 tests passed.
   - Completed a full FE/BE build with Checkstyle through the workspace 
wrapper, which invokes build.sh --be --fe -j50.
   - Verified a live single-FE/single-BE cluster with ordinary OLAP tables: 
concurrent EXPLAIN, DROP DATABASE and RECOVER DATABASE produced the expected 
lock timeout while preserving the recycled database and table. Retrying 
recovery returned the original row (1, 5). Recovery with a new name and DDL 
after an unknown-database recovery failure also succeeded.
   
   ### Release note
   
   RECOVER DATABASE leaves the database available in the recycle bin when 
catalog-lock acquisition times out, allowing a subsequent recovery attempt.
   
   ### Check List (For Author)
   
   - Behavior changed: Yes (lock-timeout failures preserve recycled database 
metadata)
   - Does this need documentation: No
   - Pre-submission status: Ready
   
   ### AI Disclosure
   
   - Tool: Codex
   - Generated: Java change, unit tests and this description
   - Human review: Pending
   


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