Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 3.9k
[fix](multi-catalog) use last used database for catalog when switch back#14793
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19 fe/fe-core/src/main/java/org/apache/doris/datasource/CatalogMgr.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -76,6 +76,8 @@ public class CatalogMgr implements Writable, GsonPostProcessable { | ||
| private final Map<Long, CatalogIf> idToCatalog = Maps.newConcurrentMap(); | ||
| // this map will be regenerated from idToCatalog, so not need to persist. | ||
| private final Map<String, CatalogIf> nameToCatalog = Maps.newConcurrentMap(); | ||
| // record last used database of every catalog | ||
| private final Map<String, String> lastDBOfCatalog = Maps.newConcurrentMap(); | ||
| // Use a separate instance to facilitate access. | ||
| // internalDataSource still exists in idToDataSource and nameToDataSource | ||
| @@ -105,6 +107,7 @@ private CatalogIf removeCatalog(long catalogId) { | ||
| if (catalog != null) { | ||
| catalog.onClose(); | ||
| nameToCatalog.remove(catalog.getName()); | ||
| lastDBOfCatalog.remove(catalog.getName()); | ||
| Env.getCurrentEnv().getExtMetaCacheMgr().removeCache(catalog.getName()); | ||
| } | ||
| return catalog; | ||
| @@ -146,6 +149,14 @@ public CatalogIf getCatalogOrAnalysisException(String name) throws AnalysisExcep | ||
| ErrorCode.ERR_UNKNOWN_CATALOG)); | ||
| } | ||
| public void addLastDBOfCatalog(String catalog, String db) { | ||
| lastDBOfCatalog.put(catalog, db); | ||
| } | ||
| public String getLastDB(String catalog) { | ||
| return lastDBOfCatalog.get(catalog); | ||
| } | ||
| public List<Long> getCatalogIds() { | ||
| return Lists.newArrayList(idToCatalog.keySet()); | ||
| } | ||
| @@ -241,6 +252,8 @@ public void dropCatalog(DropCatalogStmt stmt) throws UserException { | ||
| CatalogLog log = CatalogFactory.constructorCatalogLog(catalog.getId(), stmt); | ||
| replayDropCatalog(log); | ||
| Env.getCurrentEnv().getEditLog().logCatalogLog(OperationType.OP_DROP_CATALOG, log); | ||
| lastDBOfCatalog.remove(stmt.getCatalogName()); | ||
Yulei-Yang marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } finally { | ||
| writeUnlock(); | ||
| } | ||
| @@ -259,6 +272,12 @@ public void alterCatalogName(AlterCatalogNameStmt stmt) throws UserException { | ||
| CatalogLog log = CatalogFactory.constructorCatalogLog(catalog.getId(), stmt); | ||
| replayAlterCatalogName(log); | ||
| Env.getCurrentEnv().getEditLog().logCatalogLog(OperationType.OP_ALTER_CATALOG_NAME, log); | ||
| String db = lastDBOfCatalog.get(stmt.getCatalogName()); | ||
| if (db != null) { | ||
| lastDBOfCatalog.remove(stmt.getCatalogName()); | ||
| lastDBOfCatalog.put(log.getNewCatalogName(), db); | ||
| } | ||
| } finally { | ||
| writeUnlock(); | ||
| } | ||
19 changes: 19 additions & 0 deletions
19 regression-test/suites/external_table_emr_p2/hive/test_external_catalog_hive.groovy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1 regression-test/suites/external_table_emr_p2/hive/test_external_hive.groovy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -56,4 +56,3 @@ suite("test_external_hive", "p2") { | ||
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.