You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Bug] EnforceMinNumRacksPerWriteQuorum is not working correctly in the isEnsembleAdheringToPlacementPolicy method of RackawareEnsemblePlacementPolicyImpl
#4501
Describe the bug
I'm a bit confused about the meaning of the enforceMinNumRacksPerWriteQuorum parameter.
When I set enforceMinNumRacksPerWriteQuorum=false and minNumRacksPerWriteQuorum=2. I ran this test expecting the result to be MEETS_STRICT, but it returned FAIL. I believe that when enforceMinNumRacksPerWriteQuorum is set to false, as long as the number of selected racks is greater than 1, the result should be MEETS_STRICT.
The problem might be in the code snippet from the isEnsembleAdheringToPlacementPolicy method: if ((racksInQuorum.size() < minNumRacksPerWriteQuorumForThisEnsemble) || (enforceMinNumRacksPerWriteQuorum && racksInQuorum.contains(getDefaultRack()))) { return PlacementPolicyAdherence.FAIL; }
The modified code, which ensures that enforceMinNumRacksPerWriteQuorum is effective, is as follows: if (enforceMinNumRacksPerWriteQuorum && (racksInQuorum.size() < minNumRacksPerWriteQuorumForThisEnsemble || racksInQuorum.contains(getDefaultRack()))) { return PlacementPolicyAdherence.FAIL; } To Reproduce
@Test
public void testIsEnsembleAdheringToPlacementPolicyWithEnableEnforceMinRacks() throws Exception {
BookieSocketAddress addr1 = new BookieSocketAddress("127.0.0.2", 3181);
BookieSocketAddress addr2 = new BookieSocketAddress("127.0.0.3", 3181);
BookieSocketAddress addr3 = new BookieSocketAddress("127.0.0.4", 3181);
StaticDNSResolver.addNodeToRack(addr1.getHostName(), "/default-region/r1");
StaticDNSResolver.addNodeToRack(addr2.getHostName(), "/default-region/r1");
StaticDNSResolver.addNodeToRack(addr3.getHostName(), "/default-region/r1");
// Update cluster
Set<BookieId> addrs = new HashSet<BookieId>();
addrs.add(addr1.toBookieId());
addrs.add(addr2.toBookieId());
addrs.add(addr3.toBookieId());
repp.onClusterChanged(addrs, new HashSet<BookieId>());
List<BookieId> ensemble = new ArrayList<>();
ensemble.add(addr1.toBookieId());
ensemble.add(addr2.toBookieId());
assertEquals("PlacementPolicyAdherence", PlacementPolicyAdherence.MEETS_STRICT,
repp.isEnsembleAdheringToPlacementPolicy(ensemble, 2, 2));
}
Steps to reproduce the behavior:
Go to '...'
Click on '....'
Scroll down to '....'
See error
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered:
BUG REPORT
Describe the bug
I'm a bit confused about the meaning of the
enforceMinNumRacksPerWriteQuorum
parameter.When I set
enforceMinNumRacksPerWriteQuorum=false
andminNumRacksPerWriteQuorum=2
. I ran this test expecting the result to be MEETS_STRICT, but it returned FAIL. I believe that when enforceMinNumRacksPerWriteQuorum is set to false, as long as the number of selected racks is greater than 1, the result should be MEETS_STRICT.The problem might be in the code snippet from the isEnsembleAdheringToPlacementPolicy method:
if ((racksInQuorum.size() < minNumRacksPerWriteQuorumForThisEnsemble) || (enforceMinNumRacksPerWriteQuorum && racksInQuorum.contains(getDefaultRack()))) { return PlacementPolicyAdherence.FAIL; }
The modified code, which ensures that enforceMinNumRacksPerWriteQuorum is effective, is as follows:
if (enforceMinNumRacksPerWriteQuorum && (racksInQuorum.size() < minNumRacksPerWriteQuorumForThisEnsemble || racksInQuorum.contains(getDefaultRack()))) { return PlacementPolicyAdherence.FAIL; }
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: