diff --git a/fe/fe-core/src/main/java/com/starrocks/alter/AlterHandler.java b/fe/fe-core/src/main/java/com/starrocks/alter/AlterHandler.java index ac97fd73568655..de4dfb8c399545 100644 --- a/fe/fe-core/src/main/java/com/starrocks/alter/AlterHandler.java +++ b/fe/fe-core/src/main/java/com/starrocks/alter/AlterHandler.java @@ -127,7 +127,8 @@ private void clearExpireFinishedOrCancelledAlterJobsV2() { Iterator> iterator = alterJobsV2.entrySet().iterator(); while (iterator.hasNext()) { AlterJobV2 alterJobV2 = iterator.next().getValue(); - long validDeletionTimeMs = GlobalStateMgr.getCurrentState().getClusterSnapshotMgr().getValidDeletionTimeMsByAutomatedSnapshot(); + long validDeletionTimeMs = GlobalStateMgr.getCurrentState().getClusterSnapshotMgr() + .getValidDeletionTimeMsByAutomatedSnapshot(); if (alterJobV2.isExpire() && alterJobV2.getFinishedTimeMs() < validDeletionTimeMs) { iterator.remove(); RemoveAlterJobV2OperationLog log = diff --git a/fe/fe-core/src/main/java/com/starrocks/catalog/CatalogRecycleBin.java b/fe/fe-core/src/main/java/com/starrocks/catalog/CatalogRecycleBin.java index ef8e2e559ccb93..47b51ce8a175e6 100644 --- a/fe/fe-core/src/main/java/com/starrocks/catalog/CatalogRecycleBin.java +++ b/fe/fe-core/src/main/java/com/starrocks/catalog/CatalogRecycleBin.java @@ -306,8 +306,15 @@ private synchronized long getAdjustedRecycleTimestamp(long id) { return Long.MAX_VALUE; // can not be erased } + Map idToRecycleTableInfo = Maps.newHashMap(); + for (Map tableEntry : idToTableInfo.rowMap().values()) { + for (Map.Entry entry : tableEntry.entrySet()) { + idToRecycleTableInfo.put(entry.getKey(), entry.getValue()); + } + } + boolean recoverable = true; - if (idToTableInfo.get(id) != null) { + if (idToRecycleTableInfo.get(id) != null) { recoverable = idToTableInfo.get(id).isRecoverable(); } else if (idToPartition.get(id) != null) { recoverable = idToPartition.get(id).isRecoverable(); diff --git a/fe/fe-core/src/main/java/com/starrocks/lake/StarMgrMetaSyncer.java b/fe/fe-core/src/main/java/com/starrocks/lake/StarMgrMetaSyncer.java index 0b51a91029561f..c245cb7d05da45 100644 --- a/fe/fe-core/src/main/java/com/starrocks/lake/StarMgrMetaSyncer.java +++ b/fe/fe-core/src/main/java/com/starrocks/lake/StarMgrMetaSyncer.java @@ -80,7 +80,8 @@ private List getAllPartitionShardGroupId() { try { for (Table table : GlobalStateMgr.getCurrentState().getLocalMetastore().getTablesIncludeRecycleBin(db)) { if (table.isCloudNativeTableOrMaterializedView() && - GlobalStateMgr.getCurrentState().getClusterSnapshotMgr().checkValidDeletionForTableFromAlterJob(table.getId())) { + GlobalStateMgr.getCurrentState().getClusterSnapshotMgr() + .checkValidDeletionForTableFromAlterJob(table.getId())) { GlobalStateMgr.getCurrentState().getLocalMetastore() .getAllPartitionsIncludeRecycleBin((OlapTable) table) .stream() diff --git a/fe/fe-core/src/main/java/com/starrocks/lake/snapshot/ClusterSnapshot.java b/fe/fe-core/src/main/java/com/starrocks/lake/snapshot/ClusterSnapshot.java index 62667abc28b9da..e71c3dd29fd0fd 100644 --- a/fe/fe-core/src/main/java/com/starrocks/lake/snapshot/ClusterSnapshot.java +++ b/fe/fe-core/src/main/java/com/starrocks/lake/snapshot/ClusterSnapshot.java @@ -31,10 +31,10 @@ public enum ClusterSnapshotType { AUTOMATED, MANUAL, INCREMENTAL } private ClusterSnapshotType type; @SerializedName(value = "storageVolumeName") private String storageVolumeName; - @SerializedName(value = "createdTime") - private long createdTime; - @SerializedName(value = "finishedTime") - private long finishedTime; + @SerializedName(value = "createdTimeMs") + private long createdTimeMs; + @SerializedName(value = "finishedTimeMs") + private long finishedTimeMs; @SerializedName(value = "feJournalId") private long feJournalId; @SerializedName(value = "starMgrJournal") @@ -42,14 +42,14 @@ public enum ClusterSnapshotType { AUTOMATED, MANUAL, INCREMENTAL } public ClusterSnapshot() {} - public ClusterSnapshot(long id, String snapshotName, String storageVolumeName, long createdTime, - long finishedTime, long feJournalId, long starMgrJournalId) { + public ClusterSnapshot(long id, String snapshotName, String storageVolumeName, long createdTimeMs, + long finishedTimeMs, long feJournalId, long starMgrJournalId) { this.id = id; this.snapshotName = snapshotName; this.type = ClusterSnapshotType.AUTOMATED; this.storageVolumeName = storageVolumeName; - this.createdTime = createdTime; - this.finishedTime = finishedTime; + this.createdTimeMs = createdTimeMs; + this.finishedTimeMs = finishedTimeMs; this.feJournalId = feJournalId; this.starMgrJournalId = starMgrJournalId; } @@ -59,8 +59,8 @@ public void setJournalIds(long feJournalId, long starMgrJournalId) { this.starMgrJournalId = starMgrJournalId; } - public void setFinishedTime(long finishedTime) { - this.finishedTime = finishedTime; + public void setFinishedTimeMs(long finishedTimeMs) { + this.finishedTimeMs = finishedTimeMs; } public String getSnapshotName() { @@ -71,12 +71,12 @@ public String getStorageVolumeName() { return storageVolumeName; } - public long getCreatedTime() { - return createdTime; + public long getCreatedTimeMs() { + return createdTimeMs; } - public long getFinishedTime() { - return finishedTime; + public long getFinishedTimeMs() { + return finishedTimeMs; } public long getFeJournalId() { @@ -95,8 +95,8 @@ public TClusterSnapshotsItem getInfo() { TClusterSnapshotsItem item = new TClusterSnapshotsItem(); item.setSnapshot_name(snapshotName); item.setSnapshot_type(type.name()); - item.setCreated_time(createdTime / 1000); - item.setFinished_time(finishedTime / 1000); + item.setCreated_time(createdTimeMs / 1000); + item.setFinished_time(finishedTimeMs / 1000); item.setFe_jouranl_id(feJournalId); item.setStarmgr_jouranl_id(starMgrJournalId); item.setProperties(""); diff --git a/fe/fe-core/src/main/java/com/starrocks/lake/snapshot/ClusterSnapshotJob.java b/fe/fe-core/src/main/java/com/starrocks/lake/snapshot/ClusterSnapshotJob.java index b6bacf6ba70af0..f9446a89920751 100644 --- a/fe/fe-core/src/main/java/com/starrocks/lake/snapshot/ClusterSnapshotJob.java +++ b/fe/fe-core/src/main/java/com/starrocks/lake/snapshot/ClusterSnapshotJob.java @@ -46,8 +46,8 @@ public enum ClusterSnapshotJobState { INITIALIZING, SNAPSHOTING, UPLOADING, FINI @SerializedName(value = "errMsg") private String errMsg; - public ClusterSnapshotJob(long id, String snapshotName, String storageVolumeName, long createdTime) { - this.snapshot = new ClusterSnapshot(id, snapshotName, storageVolumeName, createdTime, -1, 0, 0); + public ClusterSnapshotJob(long id, String snapshotName, String storageVolumeName, long createdTimeMs) { + this.snapshot = new ClusterSnapshot(id, snapshotName, storageVolumeName, createdTimeMs, -1, 0, 0); this.state = ClusterSnapshotJobState.INITIALIZING; this.errMsg = ""; } @@ -55,7 +55,7 @@ public ClusterSnapshotJob(long id, String snapshotName, String storageVolumeName public void setState(ClusterSnapshotJobState state) { this.state = state; if (state == ClusterSnapshotJobState.FINISHED) { - snapshot.setFinishedTime(System.currentTimeMillis()); + snapshot.setFinishedTimeMs(System.currentTimeMillis()); } } @@ -75,12 +75,12 @@ public String getStorageVolumeName() { return snapshot.getStorageVolumeName(); } - public long getCreatedTime() { - return snapshot.getCreatedTime(); + public long getCreatedTimeMs() { + return snapshot.getCreatedTimeMs(); } - public long getFinishedTime() { - return snapshot.getFinishedTime(); + public long getFinishedTimeMs() { + return snapshot.getFinishedTimeMs(); } public long getFeJournalId() { @@ -123,8 +123,8 @@ public TClusterSnapshotJobsItem getInfo() { TClusterSnapshotJobsItem item = new TClusterSnapshotJobsItem(); item.setSnapshot_name(getSnapshotName()); item.setJob_id(getId()); - item.setCreated_time(getCreatedTime() / 1000); - item.setFinished_time(getFinishedTime() / 1000); + item.setCreated_time(getCreatedTimeMs() / 1000); + item.setFinished_time(getFinishedTimeMs() / 1000); item.setState(state.name()); item.setDetail_info(""); item.setError_message(errMsg); diff --git a/fe/fe-core/src/main/java/com/starrocks/lake/snapshot/ClusterSnapshotMgr.java b/fe/fe-core/src/main/java/com/starrocks/lake/snapshot/ClusterSnapshotMgr.java index d63a7441add2c2..5ec5557231201f 100644 --- a/fe/fe-core/src/main/java/com/starrocks/lake/snapshot/ClusterSnapshotMgr.java +++ b/fe/fe-core/src/main/java/com/starrocks/lake/snapshot/ClusterSnapshotMgr.java @@ -109,7 +109,7 @@ protected void addAutomatedClusterSnapshot(ClusterSnapshot newAutomatedClusterSn GlobalStateMgr.getCurrentState().getEditLog().logClusterSnapshotLog(log); if (automatedSnapshot != null && automatedSnapshot.getSnapshotName().startsWith(AUTOMATED_NAME_PREFIX)) { - previousAutomatedSnapshotCreatedTimsMs = automatedSnapshot.getCreatedTime(); + previousAutomatedSnapshotCreatedTimsMs = automatedSnapshot.getCreatedTimeMs(); try { ClusterSnapshotUtils.clearAutomatedSnapshotFromRemote(automatedSnapshot.getSnapshotName()); } catch (StarRocksException e) { @@ -121,11 +121,11 @@ protected void addAutomatedClusterSnapshot(ClusterSnapshot newAutomatedClusterSn } public ClusterSnapshotJob createAutomatedSnapshotJob() { - long createTime = System.currentTimeMillis(); + long createTimeMs = System.currentTimeMillis(); long id = GlobalStateMgr.getCurrentState().getNextId(); - String snapshotName = AUTOMATED_NAME_PREFIX + '_' + String.valueOf(createTime); + String snapshotName = AUTOMATED_NAME_PREFIX + '_' + String.valueOf(createTimeMs); String storageVolumeName = automatedSnapshotSvName; - ClusterSnapshotJob job = new ClusterSnapshotJob(id, snapshotName, storageVolumeName, createTime); + ClusterSnapshotJob job = new ClusterSnapshotJob(id, snapshotName, storageVolumeName, createTimeMs); job.logJob(); addJob(job);