Skip to content

Commit

Permalink
fix concurrent-safety of AlterMaterializedViewTest.testMVOnMVReload
Browse files Browse the repository at this point in the history
Signed-off-by: Murphy <[email protected]>
  • Loading branch information
murphyatwork committed Dec 6, 2024
1 parent aa36526 commit 1a5e7b9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -584,22 +584,22 @@ public void setDbId(long dbId) {
this.dbId = dbId;
}

public boolean isActive() {
public synchronized boolean isActive() {
return active;
}

/**
* active the materialized again & reload the state.
*/
public void setActive() {
public synchronized void setActive() {
LOG.info("set {} to active", name);
// reset mv rewrite cache when it is active again
CachingMvPlanContextBuilder.getInstance().updateMvPlanContextCache(this, true);
this.active = true;
this.inactiveReason = null;
}

public void setInactiveAndReason(String reason) {
public synchronized void setInactiveAndReason(String reason) {
LOG.warn("set {} to inactive because of {}", name, reason);
this.active = false;
this.inactiveReason = reason;
Expand All @@ -611,14 +611,14 @@ public void setInactiveAndReason(String reason) {
/**
* Reset cached metadata when mv's meta has changed.
*/
public void resetMetadataCache() {
public synchronized void resetMetadataCache() {
refBaseTablePartitionExprsOpt = Optional.empty();
refBaseTablePartitionSlotsOpt = Optional.empty();
refBaseTablePartitionColumnsOpt = Optional.empty();
tableToBaseTableInfoCache.clear();
}

public String getInactiveReason() {
public synchronized String getInactiveReason() {
return inactiveReason;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,15 @@ public Runnable getRunnable() {
public synchronized void start() {
if (isRunning.compareAndSet(false, true)) {
isStopped.set(false);
super.start();
if (getState() == State.NEW) {
super.start();
}
}
}

public void setStop() {
isStopped.set(true);
super.interrupt();
}

public boolean isRunning() {
Expand Down

0 comments on commit 1a5e7b9

Please sign in to comment.