Skip to content

Issue 1898: Implement isEnsembleAdheringToPlacementPolicy in RegionAwareEnsemblePlacementPolicy #4133

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

dragonls
Copy link
Contributor

Master Issue: #1898

Motivation

Before this PR, isEnsembleAdheringToPlacementPolicy in RegionAwareEnsemblePlacementPolicy always return PlacementPolicyAdherence.MEETS_STRICT, which is not good to keep data highly available while using RegionAwareEnsemblePlacementPolicy , especially when one region is down.

Changes

Implement isEnsembleAdheringToPlacementPolicy in RegionAwareEnsemblePlacementPolicy.

The main implementation idea is that when all allocations are satisfied in different regions, it is considered PlacementPolicyAdherence.MEETS_STRICT, otherwise PlacementPolicyAdherence.FAIL.

@hangc0276
Copy link
Contributor

@horizonzy Please help take a look at this PR, thanks.

@hangc0276
Copy link
Contributor

@dragonls Thanks for your contribution. Would you please fix the failed check style? thanks.

@dragonls
Copy link
Contributor Author

@dragonls Thanks for your contribution. Would you please fix the failed check style? thanks.

Fixed.

return PlacementPolicyAdherence.FAIL;
}

if (regionsInQuorum.size() < 2) {
Copy link
Member

Choose a reason for hiding this comment

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

I have a question: why judge the regionsInQuorum.size() < 2?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The purpose of doing this here is to align the implement in org.apache.bookkeeper.client.RegionAwareEnsemblePlacementPolicy#newEnsemble:

// Single region, fall back to RackAwareEnsemblePlacement
if (numRegionsAvailable < 2) {
RRTopologyAwareCoverageEnsemble ensemble = new RRTopologyAwareCoverageEnsemble(ensembleSize,
writeQuorumSize, ackQuorumSize, REGIONID_DISTANCE_FROM_LEAVES,
effectiveMinRegionsForDurability > 0 ? new HashSet<>(perRegionPlacement.keySet()) : null,
effectiveMinRegionsForDurability, minNumRacksPerWriteQuorum);
TopologyAwareEnsemblePlacementPolicy nextPolicy = perRegionPlacement.get(
availableRegions.iterator().next());
return nextPolicy.newEnsemble(ensembleSize, writeQuorumSize, writeQuorumSize,
comprehensiveExclusionBookiesSet, ensemble, ensemble);
}

When there is only one available region, fall back to RackAwareEnsemblePlacement.

Copy link
Member

Choose a reason for hiding this comment

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

It's a little weird.
Based on: writeQuorumSize = 3.

If regionsInQuorum < 2, the result may be MEETS_STRICT.

If regionsInQuorum = 2, the result is FAIL.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, a little weird.

Should we just remove the numRegionsAvailable < 2 judge in isEnsembleAdheringToPlacementPolicy? May I have your suggestion?

Copy link
Member

Choose a reason for hiding this comment

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

The PlacementPolicyAdherence enum has three values FAIL(1), MEETS_SOFT(3), MEETS_STRICT(5).
If there are enough different region, the result could be MEETS_STRICT. If there aren't enough different region, the each RackAwarePLacementPolicy MEETS_STRICT, the result could be MEETS_SOFT

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

@dragonls dragonls requested a review from horizonzy February 5, 2024 03:12
comprehensiveExclusionBookiesSet, ensemble, ensemble);
return PlacementResult.of(placementResult.getResult(),
isEnsembleAdheringToPlacementPolicy(
Copy link
Member

Choose a reason for hiding this comment

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

Here, we can simplify the logic. We already know there is only one region.
Just need check the result of nextPolicy.newEnsemble.

  1. If the result is PlacementPolicyAdherence.FAIL, return directly.
  2. If the result is PlacementPolicyAdherence.MEETS_STRICT, then check whether minNumRacksPerWriteQuorum is more than 1. If it is, return PlacementPolicyAdherence.SOFT, otherwise return PlacementPolicyAdherence.MEETS_STRICT.

@eolivelli eolivelli modified the milestones: 4.17.0, 4.18.0 Mar 29, 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.

4 participants