Skip to content
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

[BugFix] Fix Attempt to unlock lock, not locked by current locker in mv refresh #51884

Merged
merged 2 commits into from
Oct 16, 2024

Conversation

LiShuMing
Copy link
Contributor

@LiShuMing LiShuMing commented Oct 14, 2024

Why I'm doing:

Fix two bugs in using mv:

  1. refresh mvs may occur some exceptions below:
2024-10-14 12:32:08.193+08:00 WARN (starrocks-taskrun-pool-5|107576) [TaskRunExecutor.lambda$executeTaskRun$0():65] failed to execute TaskRun.
com.starrocks.sql.common.DmlException: Refresh materialized view hitted_mv_dw_bbzdb_bas_servicetype failed after retrying 1 times(try-lock 0 times), error-msg : java.lang.IllegalMonitorStateException: Attempt to unlock lock, not locked by current locker
	at com.starrocks.common.util.concurrent.lock.MultiUserLock.release(MultiUserLock.java:182)
	at com.starrocks.common.util.concurrent.lock.LockManager.release(LockManager.java:275)
	at com.starrocks.common.util.concurrent.lock.Locker.release(Locker.java:106)
	at com.starrocks.common.util.concurrent.lock.Locker.unLockTablesWithIntensiveDbLock(Locker.java:417)
	at com.starrocks.common.util.concurrent.lock.Locker.tryLockTableWithIntensiveDbLock(Locker.java:521)
	at com.starrocks.common.util.concurrent.lock.Locker.tryLockTableWithIntensiveDbLock(Locker.java:504)
	at com.starrocks.scheduler.PartitionBasedMvRefreshProcessor.checkMvToRefreshedPartitions(PartitionBasedMvRefreshProcessor.java:280)
	at com.starrocks.scheduler.PartitionBasedMvRefreshProcessor.doRefreshMaterializedView(PartitionBasedMvRefreshProcessor.java:412)
	at com.starrocks.scheduler.PartitionBasedMvRefreshProcessor.doRefreshMaterializedViewWithRetry(PartitionBasedMvRefreshProcessor.java:366)
	at com.starrocks.scheduler.PartitionBasedMvRefreshProcessor.doMvRefresh(PartitionBasedMvRefreshProcessor.java:325)
	at com.starrocks.scheduler.PartitionBasedMvRefreshProcessor.processTaskRun(PartitionBasedMvRefreshProcessor.java:199)
	at com.starrocks.scheduler.TaskRun.executeTaskRun(TaskRun.java:270)
	at com.starrocks.scheduler.TaskRunExecutor.lambda$executeTaskRun$0(TaskRunExecutor.java:58)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)
	at com.starrocks.scheduler.PartitionBasedMvRefreshProcessor.doRefreshMaterializedViewWithRetry(PartitionBasedMvRefreshProcessor.java:387) ~[starrocks-fe.jar:?]
	at com.starrocks.scheduler.PartitionBasedMvRefreshProcessor.doMvRefresh(PartitionBasedMvRefreshProcessor.java:325) ~[starrocks-fe.jar:?]
	at com.starrocks.scheduler.PartitionBasedMvRefreshProcessor.processTaskRun(PartitionBasedMvRefreshProcessor.java:199) ~[starrocks-fe.jar:?]
	at com.starrocks.scheduler.TaskRun.executeTaskRun(TaskRun.java:270) ~[starrocks-fe.jar:?]
	at com.starrocks.scheduler.TaskRunExecutor.lambda$executeTaskRun$0(TaskRunExecutor.java:58) ~[starrocks-fe.jar:?]
	at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700) ~[?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[?:?]
	at java.lang.Thread.run(Thread.java:829) ~[?:?]
Caused by: java.lang.IllegalMonitorStateException: Attempt to unlock lock, not locked by current locker
	at com.starrocks.common.util.concurrent.lock.MultiUserLock.release(MultiUserLock.java:182) ~[starrocks-fe.jar:?]
	at com.starrocks.common.util.concurrent.lock.LockManager.release(LockManager.java:275) ~[starrocks-fe.jar:?]
	at com.starrocks.common.util.concurrent.lock.Locker.release(Locker.java:106) ~[starrocks-fe.jar:?]
	at com.starrocks.common.util.concurrent.lock.Locker.unLockTablesWithIntensiveDbLock(Locker.java:417) ~[starrocks-fe.jar:?]
	at com.starrocks.common.util.concurrent.lock.Locker.tryLockTableWithIntensiveDbLock(Locker.java:521) ~[starrocks-fe.jar:?]
	at com.starrocks.common.util.concurrent.lock.Locker.tryLockTableWithIntensiveDbLock(Locker.java:504) ~[starrocks-fe.jar:?]
	at com.starrocks.scheduler.PartitionBasedMvRefreshProcessor.checkMvToRefreshedPartitions(PartitionBasedMvRefreshProcessor.java:280) ~[starrocks-fe.jar:?]
	at com.starrocks.scheduler.PartitionBasedMvRefreshProcessor.doRefreshMaterializedView(PartitionBasedMvRefreshProcessor.java:412) ~[starrocks-fe.jar:?]
	at com.starrocks.scheduler.PartitionBasedMvRefreshProcessor.doRefreshMaterializedViewWithRetry(PartitionBasedMvRefreshProcessor.java:366) ~[starrocks-fe.jar:?]
	... 8 more
  1. query will be rewritten wrong if contains col in (upper('a'), lower('a');

What I'm doing:

    1. Unlock is not safe if batch locks fail, add try-catch to avoid this.
    1. Using Maps.newTreeMap() instead of CASE_INSENSITIVE_ORDER to avoid this.

Fixes #issue

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • Feature removed
  • Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function
  • This is a backport pr

Bugfix cherry-pick branch check:

  • I have checked the version labels which the pr will be auto-backported to the target branch
    • 3.3
    • 3.2
    • 3.1
    • 3.0
    • 2.5

@LiShuMing LiShuMing requested review from a team as code owners October 14, 2024 09:25
@github-actions github-actions bot added the 3.3 label Oct 14, 2024
@LiShuMing LiShuMing requested a review from a team as a code owner October 14, 2024 11:58
satanson
satanson previously approved these changes Oct 15, 2024
@@ -70,7 +70,7 @@ public class MvNormalizePredicateRule extends NormalizePredicateRule {
@Override
public ScalarOperator visitCompoundPredicate(CompoundPredicateOperator predicate,
ScalarOperatorRewriteContext context) {
Map<String, ScalarOperator> sorted = Maps.newTreeMap(String.CASE_INSENSITIVE_ORDER);
Map<String, ScalarOperator> sorted = Maps.newTreeMap();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if changed, the column name would be case-sensitive, which means behavior change ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add more comments, PTAL.

murphyatwork
murphyatwork previously approved these changes Oct 15, 2024
Signed-off-by: shuming.li <[email protected]>
Copy link

Copy link

[Java-Extensions Incremental Coverage Report]

pass : 0 / 0 (0%)

Copy link

[FE Incremental Coverage Report]

pass : 6 / 6 (100.00%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 com/starrocks/sql/optimizer/rewrite/scalar/MvNormalizePredicateRule.java 5 5 100.00% []
🔵 com/starrocks/common/util/concurrent/lock/Locker.java 1 1 100.00% []

Copy link

[BE Incremental Coverage Report]

pass : 0 / 0 (0%)

@kangkaisen kangkaisen merged commit a1a3130 into StarRocks:main Oct 16, 2024
48 checks passed
Copy link

@Mergifyio backport branch-3.3

@github-actions github-actions bot removed the 3.3 label Oct 16, 2024
Copy link
Contributor

mergify bot commented Oct 16, 2024

backport branch-3.3

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Oct 16, 2024
…mv refresh (#51884)

Signed-off-by: shuming.li <[email protected]>
(cherry picked from commit a1a3130)

# Conflicts:
#	fe/fe-core/src/main/java/com/starrocks/common/util/concurrent/lock/Locker.java
#	fe/fe-core/src/test/java/com/starrocks/planner/MaterializedViewTest.java
wanpengfei-git pushed a commit that referenced this pull request Oct 17, 2024
…mv refresh (backport #51884) (#51965)

Signed-off-by: shuming.li <[email protected]>
Co-authored-by: shuming.li <[email protected]>
mergify bot added a commit that referenced this pull request Oct 17, 2024
…mv refresh (backport #51884) (#51965)

Signed-off-by: shuming.li <[email protected]>
Co-authored-by: shuming.li <[email protected]>
(cherry picked from commit 5387fe8)
wanpengfei-git pushed a commit that referenced this pull request Oct 17, 2024
…mv refresh (backport #51884) (backport #51965) (#52043)

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
ZiheLiu pushed a commit to ZiheLiu/starrocks that referenced this pull request Oct 31, 2024
@github-actions github-actions bot added the 3.3 label Nov 5, 2024
@LiShuMing
Copy link
Contributor Author

@mergify cherry-pick branch-3.2

Copy link
Contributor

mergify bot commented Nov 5, 2024

cherry -pick branch-3.2

❌ Sorry but I didn't understand the command. Please consult the commands documentation 📚.

@LiShuMing
Copy link
Contributor Author

@mergify backport branch-3.2

@LiShuMing
Copy link
Contributor Author

@mergify backport branch-3.1

Copy link
Contributor

mergify bot commented Nov 5, 2024

backport branch-3.2

✅ Backports have been created

Copy link
Contributor

mergify bot commented Nov 5, 2024

backport branch-3.1

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Nov 5, 2024
…mv refresh (#51884)

Signed-off-by: shuming.li <[email protected]>
(cherry picked from commit a1a3130)

# Conflicts:
#	fe/fe-core/src/main/java/com/starrocks/common/util/concurrent/lock/Locker.java
#	fe/fe-core/src/test/java/com/starrocks/planner/MaterializedViewTest.java
mergify bot pushed a commit that referenced this pull request Nov 5, 2024
…mv refresh (#51884)

Signed-off-by: shuming.li <[email protected]>
(cherry picked from commit a1a3130)

# Conflicts:
#	fe/fe-core/src/main/java/com/starrocks/common/util/concurrent/lock/Locker.java
#	fe/fe-core/src/test/java/com/starrocks/planner/MaterializedViewTest.java
wanpengfei-git pushed a commit that referenced this pull request Nov 5, 2024
…mv refresh (backport #51884) (#52647)

Signed-off-by: shuming.li <[email protected]>
Co-authored-by: shuming.li <[email protected]>
wanpengfei-git pushed a commit that referenced this pull request Nov 6, 2024
…mv refresh (backport #51884) (#52648)

Signed-off-by: shuming.li <[email protected]>
Co-authored-by: shuming.li <[email protected]>
renzhimin7 pushed a commit to renzhimin7/starrocks that referenced this pull request Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants