Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: srlch <[email protected]>
  • Loading branch information
srlch committed Jan 13, 2025
1 parent e0a1ffd commit d98a789
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ private void clearExpireFinishedOrCancelledAlterJobsV2() {
Iterator<Map.Entry<Long, AlterJobV2>> 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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,15 @@ private synchronized long getAdjustedRecycleTimestamp(long id) {
return Long.MAX_VALUE; // can not be erased
}

Map<Long, RecycleTableInfo> idToRecycleTableInfo = Maps.newHashMap();
for (Map<Long, RecycleTableInfo> tableEntry : idToTableInfo.rowMap().values()) {
for (Map.Entry<Long, RecycleTableInfo> 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ private List<Long> 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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,25 @@ 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")
private long starMgrJournalId;

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;
}
Expand All @@ -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() {
Expand All @@ -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() {
Expand All @@ -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("");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ 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 = "";
}

public void setState(ClusterSnapshotJobState state) {
this.state = state;
if (state == ClusterSnapshotJobState.FINISHED) {
snapshot.setFinishedTime(System.currentTimeMillis());
snapshot.setFinishedTimeMs(System.currentTimeMillis());
}
}

Expand All @@ -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() {
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
Expand Down

0 comments on commit d98a789

Please sign in to comment.