Skip to content
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

[Bug] EnforceMinNumRacksPerWriteQuorum is not working correctly in the isEnsembleAdheringToPlacementPolicy method of RackawareEnsemblePlacementPolicyImpl #4501

Open
danpi opened this issue Sep 4, 2024 · 0 comments
Labels

Comments

@danpi
Copy link

danpi commented Sep 4, 2024

BUG REPORT

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:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. 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.

@danpi danpi added the type/bug label Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant