Skip to content

Commit d172147

Browse files
authored
[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 <!-- At least one of them must be included. --> - [ ] 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 <!-- Add your reason? --> - Behavior changed: - [x] No. - [ ] Yes. <!-- Explain the behavior change --> - Does this need documentation? - [x] No. - [ ] Yes. <!-- Add document PR link here. eg: apache/doris-website#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 -->
1 parent fa40415 commit d172147

File tree

2 files changed

+38
-41
lines changed

2 files changed

+38
-41
lines changed

fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,8 @@ public void unregisterTempTable(Table table) {
861861
}
862862

863863
private void refreshSession(String sessionId) {
864-
sessionReportTimeMap.put(sessionId, System.currentTimeMillis());
864+
// TODO: do nothing now until we fix memory link on Env#sessionReportTimeMap and Env#aliveSessionSet
865+
// sessionReportTimeMap.put(sessionId, System.currentTimeMillis());
865866
}
866867

867868
public void checkAndRefreshSession(String sessionId) {
@@ -7365,7 +7366,8 @@ private void replayJournalsAndExit() {
73657366
}
73667367

73677368
public void registerSessionInfo(String sessionId) {
7368-
this.aliveSessionSet.add(sessionId);
7369+
// TODO: do nothing now until we fix memory link on Env#sessionReportTimeMap and Env#aliveSessionSet
7370+
// this.aliveSessionSet.add(sessionId);
73697371
}
73707372

73717373
public void unregisterSessionInfo(String sessionId) {

fe/fe-core/src/main/java/org/apache/doris/catalog/TemporaryTableMgr.java

Lines changed: 34 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,11 @@
1717

1818
package org.apache.doris.catalog;
1919

20-
import org.apache.doris.common.Config;
2120
import org.apache.doris.common.util.MasterDaemon;
22-
import org.apache.doris.common.util.Util;
2321

2422
import org.apache.logging.log4j.LogManager;
2523
import org.apache.logging.log4j.Logger;
2624

27-
import java.util.Collection;
28-
import java.util.Date;
29-
import java.util.Map;
30-
3125
/*
3226
* Delete temporary table when its creating session is gone
3327
*/
@@ -41,38 +35,39 @@ public TemporaryTableMgr() {
4135

4236
@Override
4337
protected void runAfterCatalogReady() {
44-
Map<String, Long> sessionReportTimeMap = Env.getCurrentEnv().getSessionReportTimeMap();
45-
long currentTs = System.currentTimeMillis();
46-
Collection<DatabaseIf<? extends TableIf>> internalDBs = Env.getCurrentEnv().getInternalCatalog().getAllDbs();
47-
for (DatabaseIf<? extends TableIf> db : internalDBs) {
48-
for (TableIf table : db.getTables()) {
49-
if (!table.isTemporary()) {
50-
continue;
51-
}
52-
53-
String sessionId = Util.getTempTableSessionId(table.getName());
54-
boolean needDelete = false;
55-
if (!sessionReportTimeMap.containsKey(sessionId)) {
56-
LOG.info("Cannot find session id for table " + table.getName());
57-
needDelete = true;
58-
} else if (currentTs > sessionReportTimeMap.get(sessionId)
59-
+ Config.loss_conn_fe_temp_table_keep_second * 1000) {
60-
LOG.info("Temporary table " + table.getName() + " is out of time: "
61-
+ new Date(sessionReportTimeMap.get(sessionId)) + ", current: " + new Date(currentTs));
62-
needDelete = true;
63-
}
64-
65-
if (needDelete) {
66-
LOG.info("Drop temporary table " + table);
67-
try {
68-
Env.getCurrentEnv().getInternalCatalog()
69-
.dropTableWithoutCheck((Database) db, (Table) table, false, true);
70-
} catch (Exception e) {
71-
LOG.error("Drop temporary table error: db: {}, table: {}",
72-
db.getFullName(), table.getName(), e);
73-
}
74-
}
75-
}
76-
}
38+
// TODO: do nothing now until we fix memory link on Env#sessionReportTimeMap and Env#aliveSessionSet
39+
// Map<String, Long> sessionReportTimeMap = Env.getCurrentEnv().getSessionReportTimeMap();
40+
// long currentTs = System.currentTimeMillis();
41+
// Collection<DatabaseIf<? extends TableIf>> internalDBs = Env.getCurrentEnv().getInternalCatalog().getAllDbs();
42+
// for (DatabaseIf<? extends TableIf> db : internalDBs) {
43+
// for (TableIf table : db.getTables()) {
44+
// if (!table.isTemporary()) {
45+
// continue;
46+
// }
47+
//
48+
// String sessionId = Util.getTempTableSessionId(table.getName());
49+
// boolean needDelete = false;
50+
// if (!sessionReportTimeMap.containsKey(sessionId)) {
51+
// LOG.info("Cannot find session id for table " + table.getName());
52+
// needDelete = true;
53+
// } else if (currentTs > sessionReportTimeMap.get(sessionId)
54+
// + Config.loss_conn_fe_temp_table_keep_second * 1000) {
55+
// LOG.info("Temporary table " + table.getName() + " is out of time: "
56+
// + new Date(sessionReportTimeMap.get(sessionId)) + ", current: " + new Date(currentTs));
57+
// needDelete = true;
58+
// }
59+
//
60+
// if (needDelete) {
61+
// LOG.info("Drop temporary table " + table);
62+
// try {
63+
// Env.getCurrentEnv().getInternalCatalog()
64+
// .dropTableWithoutCheck((Database) db, (Table) table, false, true);
65+
// } catch (Exception e) {
66+
// LOG.error("Drop temporary table error: db: {}, table: {}",
67+
// db.getFullName(), table.getName(), e);
68+
// }
69+
// }
70+
// }
71+
// }
7772
}
7873
}

0 commit comments

Comments
 (0)