You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bookkeeper.apache.org by "danpi (via GitHub)" <gi...@apache.org> on 2024/09/04 11:53:58 UTC

[I] [Bug] EnforceMinNumRacksPerWriteQuorum is not working correctly in the isEnsembleAdheringToPlacementPolicy method of RackawareEnsemblePlacementPolicyImpl [bookkeeper]

danpi opened a new issue, #4501:
URL: https://github.com/apache/bookkeeper/issues/4501

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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@bookkeeper.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org