github-actions[bot] commented on code in PR #62950:
URL: https://github.com/apache/doris/pull/62950#discussion_r3178529884


##########
fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java:
##########
@@ -726,9 +731,17 @@ public void replayRecoverDatabase(RecoverInfo info) {
         // add db to catalog
         replayCreateDb(db, newDbName);
         db.unmarkDropped();
+        registerDbFunctionsToNereids(db);
         LOG.info("replay recover db[{}]", dbId);
     }
 
+    private void registerDbFunctionsToNereids(Database db) {
+        // A recovered database reuses catalog Function objects, so rebuild 
their Nereids builders.
+        for (Function function : db.getFunctions()) {
+            FunctionUtil.translateToNereids(db.getFullName(), function);

Review Comment:
   This rebuild handles explicit `RECOVER DATABASE`, but the stale-registry 
problem can still come back after an FE restart while the dropped DB is still 
in the recycle bin. `CatalogRecycleBin.read()` deserializes each recycled 
database via `Database.read()`, and `Database.gsonPostProcess()` iterates 
`name2Function` and calls `FunctionUtil.translateToNereids(this.getFullName(), 
function)`. Those databases are not in `fullNameToDb`, but their UDF builders 
get added back to the process-wide `FunctionRegistry` under the original DB 
name. After restart, recreating a DB with the same name can again resolve the 
stale builder from the recycled DB. Please either prevent recycled databases 
from registering functions during image load or clear those DB-scoped registry 
entries after loading/replaying the recycle bin, and add a restart/image-load 
regression or unit coverage for drop-db-with-UDF followed by recreate.



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