Skip to content

[BugFix] Relax DB lock to intensive path in qe/ read-only paths (backport #73067)#73189

Merged
wanpengfei-git merged 5 commits into
branch-4.0from
mergify/bp/branch-4.0/pr-73067
May 13, 2026
Merged

[BugFix] Relax DB lock to intensive path in qe/ read-only paths (backport #73067)#73189
wanpengfei-git merged 5 commits into
branch-4.0from
mergify/bp/branch-4.0/pr-73067

Conversation

@mergify
Copy link
Copy Markdown
Contributor

@mergify mergify Bot commented May 13, 2026

Switch four single-table read paths in qe/ from full DB READ to IS+table-READ via lockTableWithIntensiveDbLock so they no longer block concurrent DDL on other tables in the same database.

  • ShowExecutor.showCreateInternalCatalogTable: move lookup outside the lock; revalidate the resolved Table reference once the intensive lock is held so concurrent DROP/RENAME between lookup and lock acquisition is reported as ERR_BAD_TABLE_ERROR rather than serving DDL from a stale Table.
  • ShowExecutor.visitShowTabletStatement (both branches): use the known/resolved tableId for table-READ; the table-by-name branch also revalidates after locking. The single-tablet branch already re-fetches under the lock and needs no extra check.
  • ConnectProcessor.handleFieldList: move lookup outside the lock; collapse the nested lock-try inside the connector-exception try into a single try-catch-finally; revalidate after locking for internal-catalog DBs (external catalog tables are not tracked by LocalMetastore).

The revalidation closes a TOCTOU window: under the old DB READ, DROP/RENAME could not interleave between lookup and use; under IS+table-READ the lookup is unprotected so the resolved Table can be removed from the DB before the lock is taken. Re-fetching by id after locking and comparing references catches that window and reports the table as not-found, matching the old semantics.

Why I'm doing:

What I'm doing:

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 pr needs auto generate documentation
  • 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
    • 4.1
    • 4.0
    • 3.5
    • 3.4

This is an automatic backport of pull request #73067 done by [Mergify](https://mergify.com).

Signed-off-by: Kevin Cai <kevin.cai@celerdata.com>
(cherry picked from commit c15972b)

# Conflicts:
#	fe/fe-core/src/main/java/com/starrocks/qe/ShowExecutor.java
@mergify mergify Bot added the conflicts label May 13, 2026
@mergify
Copy link
Copy Markdown
Contributor Author

mergify Bot commented May 13, 2026

Cherry-pick of c15972b has failed:

On branch mergify/bp/branch-4.0/pr-73067
Your branch is up to date with 'origin/branch-4.0'.

You are currently cherry-picking commit c15972b5ad.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   fe/fe-core/src/main/java/com/starrocks/qe/ConnectProcessor.java

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   fe/fe-core/src/main/java/com/starrocks/qe/ShowExecutor.java

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@mergify
Copy link
Copy Markdown
Contributor Author

mergify Bot commented May 13, 2026

@mergify[bot]: Backport conflict, please reslove the conflict and resubmit the pr

@kevincai kevincai reopened this May 13, 2026
@wanpengfei-git wanpengfei-git enabled auto-merge (squash) May 13, 2026 03:13
@kevincai
Copy link
Copy Markdown
Contributor

@copilot try to fix the backport code conflict, strict to only the necessary code change from main branch.

auto-merge was automatically disabled May 13, 2026 03:24

Head branch was pushed to by a user without write access

Copilot AI and others added 2 commits May 13, 2026 03:25
@wanpengfei-git wanpengfei-git enabled auto-merge (squash) May 13, 2026 03:26
Copy link
Copy Markdown
Contributor

Copilot AI commented May 13, 2026

@copilot try to fix the backport code conflict, strict to only the necessary code change from main branch.

Fixed in c58189c. I resolved the ShowExecutor backport conflict by keeping only the branch-4.0-adapted lock-relaxation changes from main, removing the leftover conflict artifacts, and keeping the sync MV fallback protected with a DB read lock.

Copilot AI requested a review from kevincai May 13, 2026 03:27
Signed-off-by: Kevin Cai <kevin.cai@celerdata.com>
@wanpengfei-git wanpengfei-git merged commit 421790c into branch-4.0 May 13, 2026
28 checks passed
@wanpengfei-git wanpengfei-git deleted the mergify/bp/branch-4.0/pr-73067 branch May 13, 2026 05:31
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.

3 participants