Skip to content

[feature](fe) Add cross-AZ success quorum check - #66751

Open
deardeng wants to merge 2 commits into
apache:masterfrom
deardeng:impl-quorum-load-fe
Open

[feature](fe) Add cross-AZ success quorum check#66751
deardeng wants to merge 2 commits into
apache:masterfrom
deardeng:impl-quorum-load-fe

Conversation

@deardeng

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: None

Related PR: #66680

Problem Summary: Load transaction commits only enforced the ordinary replica quorum and could therefore succeed without a configured minimum number of successful replicas in each availability zone. Add a mutable FE configuration and enforce the per-AZ success floor in the centralized transaction commit check. Clamp each AZ requirement to the partition declared replica allocation so backend liveness changes and transient extra replicas do not weaken or inflate the commit requirement.

Release note

Add the mutable FE configuration cross_az_succ_quorum to require a minimum number of successful load replicas per availability zone.

Check List (For Author)

  • Test: Unit Test
    • DatabaseTransactionMgrTest cross-AZ quorum, unavailable replica, and extra replica cases
  • Behavior changed: Yes (when cross_az_succ_quorum is configured, FE rejects commits that do not meet the per-AZ success floor)
  • Does this need documentation: No

What problem does this PR solve?

Issue Number: close #xxx

Related PR: #xxx

Problem Summary:

Release note

None

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
  • Behavior changed:

    • No.
    • Yes.
  • 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

### What problem does this PR solve?

Issue Number: None

Related PR: apache#66680

Problem Summary: Load transaction commits only enforced the ordinary replica quorum and could therefore succeed without a configured minimum number of successful replicas in each availability zone. Add a mutable FE configuration and enforce the per-AZ success floor in the centralized transaction commit check. Clamp each AZ requirement to the partition declared replica allocation so backend liveness changes and transient extra replicas do not weaken or inflate the commit requirement.

### Release note

Add the mutable FE configuration cross_az_succ_quorum to require a minimum number of successful load replicas per availability zone.

### Check List (For Author)

- Test: Unit Test
    - DatabaseTransactionMgrTest cross-AZ quorum, unavailable replica, and extra replica cases
- Behavior changed: Yes (when cross_az_succ_quorum is configured, FE rejects commits that do not meet the per-AZ success floor)
- Does this need documentation: No
@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?

@deardeng

Copy link
Copy Markdown
Contributor Author

run buildall

@deardeng

Copy link
Copy Markdown
Contributor Author

/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.

Requesting changes because the opt-in cross-AZ durability policy is not end-to-end safe yet.

Blocking findings:

  1. The FE adds a distribution-specific check after both BE writer generations have already finalized commit infos using only the ordinary scalar quorum, so a healthy slower required-AZ replica can be omitted permanently.
  2. Startup and mutable config updates accept malformed or duplicate policy entries, while the lazy parser silently drops or overwrites them and enforces a weaker policy.
  3. Commit classification reads a backend location tag that MODIFY BACKEND mutates without safe publication, so it can enforce the policy against stale topology.

Critical checkpoint conclusions:

  • Goal and proof: The local FE check expresses the requested floor, but the three findings mean the end-to-end goal is not accomplished; direct FE tests with fabricated commit infos do not prove the writer-to-commit path.
  • Scope and clarity: The three-file patch is locally focused and readable, but the required planner/BE producer handoff and validation boundary are missing.
  • Concurrency and locks: Config cache publication is safe for the supported replace-on-update path. Table locks stabilize partition/index metadata, but not backend tag publication; no additional lock-order or deadlock issue was found.
  • Lifecycle and statics: The process-static cache has a coherent replacement lifecycle, with no circular initialization or resource-release issue.
  • Dynamic configuration: The master observes replacement arrays promptly, but malformed values fail open. Master-only failover behavior otherwise matches adjacent mutable-config semantics.
  • Compatibility: No persisted or symbol format changes are introduced, but current and older BEs receive no AZ-aware completion criterion or capability fence, so rolling deployment is unsafe when the feature is enabled.
  • Parallel paths: Ordinary non-cloud transaction sources, local 2PC at precommit, and each subtransaction reach checkCommitStatus; final 2PC correctly preserves the prepared decision. Cloud uses a distinct meta-service transaction model. Auto-partition is exposed to the same writer handoff defect.
  • Conditions: Allocation clamping and the zero-requirement skip match the declared-allocation policy; dead, bad, missing, decommissioned, extra, and loaded schema-change replicas yielded no separate defect.
  • Test coverage: The added tests cover direct success/failure, clamping, unavailable/bad replicas, and an extra replica. They miss end-to-end v1/v2 delayed-remote behavior, startup/admin rejection, and the backend-topology concurrency boundary.
  • Test results: Compile, CheckStyle, and several static checks are green; FE UT and regression/performance jobs were still pending at review time. No local tests were run because this workflow is review-only.
  • Observability: Failure logs include transaction, tablet, table, partition, version, AZ, and replica detail. No separate logging/metrics blocker was found.
  • Transactions and persistence: The check runs before commit or precommit state advancement; no edit-log payload is added, and prepared-state failover semantics remain intact.
  • Writes and crashes: Existing atomic state transitions remain in place and no new leak/crash path was found, but the missing producer contract can turn a healthy load into a terminal commit failure.
  • FE/BE variables: The AZ requirement is not passed or translated into an equivalent requirement on either initial or auto-partition writer paths; this is the first blocking finding.
  • Performance: Parsing is amortized once per config replacement and backend tags are cached once per commit; no distinct material performance problem was found.
  • Other issues and user focus: No additional user focus was supplied, and the full-PR sweep found no valuable issue beyond the three inline findings.

Comment thread fe/fe-common/src/main/java/org/apache/doris/common/Config.java
if (!crossAzSuccQuorum.isEmpty()) {
backendLocationTags.computeIfAbsent(tabletBackend, backendId -> {
Backend backend = env.getCurrentSystemInfo().getBackend(backendId);
return backend == null ? "" : backend.getLocationTag().value;

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.

Consume a safely published backend-location snapshot here. MODIFY BACKEND calls setTagMap on an already-published Backend, but locationTag is non-volatile and unsynchronized, and that update does not republish the volatile backend map; this commit thread shares neither the writer's monitor nor another happens-before edge. After an az1 backend is relabeled to az2, a stale az1 read can count one success in each zone although both current successes are in az2. Publish the location through an immutable/volatile snapshot or shared synchronization, and test concurrent relabel/commit behavior around the defined snapshot boundary.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is intentional feature behavior. Invalid entries are skipped with a warning, while valid entries remain effective. We do not want one malformed entry to reject the entire dynamic configuration update.

### What problem does this PR solve?

Issue Number: None

Related PR: apache#66751

Problem Summary: Backend location tags can be updated by MODIFY BACKEND while transaction commit threads read them. The plain locationTag reference had no Java memory-model publication edge, so readers could observe a stale availability-zone tag. Publish replacement Tag instances through a volatile reference and add a deterministic regression test for the required publication semantics.

### Release note

None

### Check List (For Author)

- Test: Unit Test
    - BackendTest#testLocationTagIsSafelyPublished
- Behavior changed: No (ensures existing backend location updates are visible across threads)
- Does this need documentation: No
@deardeng

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 89.66% (26/29) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 0.22% (1/459) 🎉
Increment coverage report
Complete coverage report

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.

2 participants