From 685571e5fc1242e4f79d8384d6e00cbb7f974d57 Mon Sep 17 00:00:00 2001 From: morrySnow Date: Mon, 5 Jan 2026 11:21:18 +0800 Subject: [PATCH] [fix](temp-table) not clean temp table temporary until fix mem leak (#59535) ### What problem does this PR solve? Related PR: #40680 Problem Summary: This pull request temporarily disables session tracking and automatic cleanup for temporary tables due to a memory leak issue involving `Env#sessionReportTimeMap` and `Env#aliveSessionSet`. The affected logic is commented out with TODO notes, and related imports are cleaned up. Session management changes: * Disabled the code that adds sessions to `aliveSessionSet` in `Env.registerSessionInfo`, preventing new session tracking until the memory leak is fixed. * Disabled the code that updates session report times in `Env.refreshSession`, pausing session activity tracking. Temporary table cleanup changes: * Commented out the logic in `TemporaryTableMgr.runAfterCatalogReady` that deletes temporary tables when their creating session is gone, halting automatic cleanup. ### Release note None ### Check List (For Author) - Test - [ ] Regression test - [ ] Unit Test - [ ] Manual test (add detailed scripts or steps below) - [x] No need to test or manual test. Explain why: - [ ] This is a refactor/code format and no logic has been changed. - [x] Previous test can cover this change. - [ ] No code files have been changed. - [ ] Other reason - Behavior changed: - [x] No. - [ ] Yes. - Does this need documentation? - [x] No. - [ ] Yes. ### Check List (For Reviewer who merge this PR) - [ ] Confirm the release note - [ ] Confirm test cases - [ ] Confirm document - [ ] Add branch pick label --- .../java/org/apache/doris/catalog/Env.java | 6 +- .../doris/catalog/TemporaryTableMgr.java | 73 +++++++++---------- 2 files changed, 38 insertions(+), 41 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java index ee473b0c806206..94ea44fd90d14b 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java @@ -865,7 +865,8 @@ public void unregisterTempTable(Table table) { } private void refreshSession(String sessionId) { - sessionReportTimeMap.put(sessionId, System.currentTimeMillis()); + // TODO: do nothing now until we fix memory link on Env#sessionReportTimeMap and Env#aliveSessionSet + // sessionReportTimeMap.put(sessionId, System.currentTimeMillis()); } public void checkAndRefreshSession(String sessionId) { @@ -7359,7 +7360,8 @@ private void replayJournalsAndExit() { } public void registerSessionInfo(String sessionId) { - this.aliveSessionSet.add(sessionId); + // TODO: do nothing now until we fix memory link on Env#sessionReportTimeMap and Env#aliveSessionSet + // this.aliveSessionSet.add(sessionId); } public void unregisterSessionInfo(String sessionId) { diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/TemporaryTableMgr.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/TemporaryTableMgr.java index 1f9bf4c8b7ccbc..a10ddb9735148d 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/TemporaryTableMgr.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/TemporaryTableMgr.java @@ -17,17 +17,11 @@ package org.apache.doris.catalog; -import org.apache.doris.common.Config; import org.apache.doris.common.util.MasterDaemon; -import org.apache.doris.common.util.Util; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import java.util.Collection; -import java.util.Date; -import java.util.Map; - /* * Delete temporary table when its creating session is gone */ @@ -41,38 +35,39 @@ public TemporaryTableMgr() { @Override protected void runAfterCatalogReady() { - Map sessionReportTimeMap = Env.getCurrentEnv().getSessionReportTimeMap(); - long currentTs = System.currentTimeMillis(); - Collection> internalDBs = Env.getCurrentEnv().getInternalCatalog().getAllDbs(); - for (DatabaseIf db : internalDBs) { - for (TableIf table : db.getTables()) { - if (!table.isTemporary()) { - continue; - } - - String sessionId = Util.getTempTableSessionId(table.getName()); - boolean needDelete = false; - if (!sessionReportTimeMap.containsKey(sessionId)) { - LOG.info("Cannot find session id for table " + table.getName()); - needDelete = true; - } else if (currentTs > sessionReportTimeMap.get(sessionId) - + Config.loss_conn_fe_temp_table_keep_second * 1000) { - LOG.info("Temporary table " + table.getName() + " is out of time: " - + new Date(sessionReportTimeMap.get(sessionId)) + ", current: " + new Date(currentTs)); - needDelete = true; - } - - if (needDelete) { - LOG.info("Drop temporary table " + table); - try { - Env.getCurrentEnv().getInternalCatalog() - .dropTableWithoutCheck((Database) db, (Table) table, false, true); - } catch (Exception e) { - LOG.error("Drop temporary table error: db: {}, table: {}", - db.getFullName(), table.getName(), e); - } - } - } - } + // TODO: do nothing now until we fix memory link on Env#sessionReportTimeMap and Env#aliveSessionSet + // Map sessionReportTimeMap = Env.getCurrentEnv().getSessionReportTimeMap(); + // long currentTs = System.currentTimeMillis(); + // Collection> internalDBs = Env.getCurrentEnv().getInternalCatalog().getAllDbs(); + // for (DatabaseIf db : internalDBs) { + // for (TableIf table : db.getTables()) { + // if (!table.isTemporary()) { + // continue; + // } + // + // String sessionId = Util.getTempTableSessionId(table.getName()); + // boolean needDelete = false; + // if (!sessionReportTimeMap.containsKey(sessionId)) { + // LOG.info("Cannot find session id for table " + table.getName()); + // needDelete = true; + // } else if (currentTs > sessionReportTimeMap.get(sessionId) + // + Config.loss_conn_fe_temp_table_keep_second * 1000) { + // LOG.info("Temporary table " + table.getName() + " is out of time: " + // + new Date(sessionReportTimeMap.get(sessionId)) + ", current: " + new Date(currentTs)); + // needDelete = true; + // } + // + // if (needDelete) { + // LOG.info("Drop temporary table " + table); + // try { + // Env.getCurrentEnv().getInternalCatalog() + // .dropTableWithoutCheck((Database) db, (Table) table, false, true); + // } catch (Exception e) { + // LOG.error("Drop temporary table error: db: {}, table: {}", + // db.getFullName(), table.getName(), e); + // } + // } + // } + // } } }