-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
[Enhancement] Migrate part of db lock to table lock in SchemaChange #43907
Conversation
@@ -2159,7 +2163,7 @@ public ShowResultSet visitShowIndexStatement(ShowIndexStmt statement, ConnectCon | |||
// do nothing | |||
} | |||
} finally { | |||
locker.unLockDatabase(db, LockType.READ); | |||
locker.unLockTablesWithIntensiveDbLock(db, Lists.newArrayList(table.getId()), LockType.READ); | |||
} | |||
return new ShowResultSet(statement.getMetaData(), rows); | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The most risky bug in this code is:
Potential null pointer exception when using the table
variable.
You can modify the code like this:
locker.lockTablesWithIntensiveDbLock(db, table != null ? Lists.newArrayList(table.getId()) : Collections.emptyList(), LockType.READ);
try {
// Existing try block code remains unchanged
} finally {
locker.unLockTablesWithIntensiveDbLock(db, table != null ? Lists.newArrayList(table.getId()) : Collections.emptyList(), LockType.READ);
}
This modification ensures that the code checks if the table
variable is null
before attempting to use it, avoiding a potential NullPointerException
.
Quality Gate failedFailed conditions See analysis details on SonarCloud Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
7c46143
to
7e28d4d
Compare
7e28d4d
to
55a2603
Compare
Signed-off-by: HangyuanLiu <[email protected]>
55a2603
to
8af7420
Compare
Quality Gate failedFailed conditions See analysis details on SonarCloud Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
[BE Incremental Coverage Report]✅ pass : 0 / 0 (0%) |
[FE Incremental Coverage Report]❌ fail : 170 / 219 (77.63%) file detail
|
|
||
MaterializedView oldMaterializedView = (MaterializedView) db.getTable(id); | ||
if (oldMaterializedView == null) { | ||
LOG.warn("Ignore change materialized view refresh scheme log because table:" + id + "is null"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LOG.warn("Ignore change materialized view refresh scheme log because table:" + id + "is null"); | |
LOG.warn("Ignore change materialized view refresh scheme log because table:" + id + " is null"); |
@Mergifyio backport branch-3.3 |
✅ Backports have been created
|
…43907) Signed-off-by: HangyuanLiu <[email protected]> (cherry picked from commit d8649e3)
…backport #43907) (#48294) Co-authored-by: Harbor Liu <[email protected]>
…43907) Signed-off-by: HangyuanLiu <[email protected]>
…43907) Signed-off-by: HangyuanLiu <[email protected]>
Why I'm doing:
What I'm doing:
Fixes #issue
What type of PR is this:
Does this PR entail a change in behavior?
If yes, please specify the type of change:
Checklist:
Bugfix cherry-pick branch check: