Skip to content

[fix](nereids) select common queryable backend for colocate buckets - #69589

Open
zhaixiangli wants to merge 1 commit into
apache:masterfrom
zhaixiangli:fix/colocate-common-queryable-backend
Open

zhaixiangli wants to merge 1 commit into
apache:masterfrom
zhaixiangli:fix/colocate-common-queryable-backend

Conversation

@zhaixiangli

Copy link
Copy Markdown

What problem does this PR solve?

Issue Number: N/A

Related PR: N/A

Problem Summary:

For colocate joins, Nereids selected the worker for a bucket from the first tablet of the first non-pruned ScanNode. It did not verify that the selected backend had a queryable replica for every tablet in the same bucket across all participating Olap ScanNodes. When replica layouts differed temporarily, assignment could fail later with Can not find tablet ... in the bucket even though another backend was common to all tablets.

This PR intersects the queryable replica backends of all tablets in the current bucket across all participating Olap ScanNodes, then applies the existing backend preference and minimum-workload selection to that common candidate list. If no common queryable backend exists, it reports an explicit analysis error. The intersection keeps a single candidate list bounded by the replica count and does not allocate a Map or Set per tablet.

Release note

Fix Nereids colocate bucket scheduling to select a queryable backend shared by all scanned tablets.

Check List (For Author)

  • Test

    • Regression test
    • Unit Test
    • Manual test (add detailed scripts or steps below)
    • No need to test or manual test. Explain why:
      • This is a refactor/code format and no logic has been changed.
      • Previous test can cover this change.
      • No code files have been changed.
      • Other reason

    Added unit tests for mismatched replica layouts, no common queryable backend, and query-disabled common replicas. The tests were not run locally; CI will verify them.

  • Behavior changed:

    • No.
    • Yes. Colocate bucket scheduling now chooses a backend common to every scanned tablet instead of selecting from only the first tablet.
  • Does this need documentation?

    • No.
    • Yes.

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

@hello-stephen

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@freemandealer

Copy link
Copy Markdown
Member

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed the full authoritative diff at head a9a902522323df1d4d610dc7c83b296b28cffd67. No substantiated new defect was found. There are no existing inline findings to carry forward and no additional user focus was supplied.

The common-backend intersection enforces the existing downstream requirement that every tablet assigned to a bucket contain the same backend. It fixes selection when the first tablet offers an unsuitable alternative; an empty intersection already made the old assignment fail. Query/load backend requirements, preferred tiers, workload accounting and each tablet's original scan range remain preserved.

Critical checkpoint conclusions:

  1. Goal and evidence: the implementation selects a queryable backend common to every scanned OLAP tablet in a bucket. Three added JUnit tests cover overlapping replicas, disjoint replicas and a query-disabled common replica. Tests were inspected, not executed.
  2. Scope and reuse: the change is limited to the selector and its backend-selection tests; the extracted replica helper reuses existing ordering, availability and workload logic.
  3. Concurrency and locking: the selector is statement-local and fragment assignments run sequentially. No new threads, locks, lock ordering or blocking work under locks is introduced. Backend availability is rechecked during selection as before.
  4. Lifecycle and initialization: candidate lists are local and short-lived. No new static initialization, ownership cycle or resource lifecycle is introduced.
  5. Configuration: no configuration is added. Existing ordered-scan and backend-selection settings retain their use sites.
  6. Compatibility: no public interface, persisted metadata, storage format or wire format changes.
  7. Thrift/protobuf: no definitions are changed; a release-branch field-ID audit is inapplicable.
  8. Parallel paths: colocate and single-scan bucket-shuffle assignments satisfy the same final per-tablet constraint. Ordinary scans retain the shared helper; the non-OLAP fallback is preserved. Cloud backend placement is resolved upstream; stable-colocate and single-partition distribution gates were checked.
  9. Conditions and errors: pruned scan-node buckets are skipped, all real tablets constrain the intersection, and invalid assignments fail explicitly. The catalog comparison uses primitive value equality; supported colocate paths preserve catalog identity. Required query candidates are filtered upstream, and required load candidates are filtered before the singleton shortcut, so intersection does not bypass those policies.
  10. Test coverage: the main positive and negative cases have focused unit tests. Added tests do not cover multiple tablets/partitions, multiple buckets, pruning, ordered mode, cloud or policy-after-intersection; those paths were inspected through their producers and consumers. No end-to-end or runtime validation was performed.
  11. Test results: no regression output files are changed. The new JUnit assertions agree with the intended assignment and error behavior; no passing build/test result is claimed.
  12. Observability: the new failure identifies the bucket with no common backend. Existing per-tablet backend-selection profiling remains; no new distributed operation requiring additional metrics was found.
  13. Transactions, persistence and failover: no transaction or EditLog mutation is added. Existing scan-range versions are forwarded unchanged.
  14. Data writes and atomicity: this is read scheduling; no write atomicity or persistent crash-recovery mechanism changes.
  15. FE/BE propagation: no transmitted variable is added. Final scan parameters still use each tablet's original range.
  16. Performance: the shrinking candidate list uses O(R) additional state and O(T * R^2) worst-case membership work for T tablets and R replicas, with early termination and no per-tablet map/set. No material performance defect was substantiated.
  17. Other invariants: visibility, delete-bitmap and BE memory-accounting mechanisms are unchanged. No optimizer rule registration/stage, slot/ExprId, mark-join or physical-property derivation is modified. No additional issue was substantiated in the final missed-case recheck.

Coverage limits: this was a static-only review, as required. No builds, tests or runtime experiments were run. Both changed files and the relevant scheduling, placement, policy and assignment paths were covered; no unresolved candidate or unreviewed changed scope remains.

Review converged after 2 round(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants