hangc0276 commented on code in PR #4889:
URL: https://github.com/apache/bookkeeper/pull/4889#discussion_r4749780008
##########
bookkeeper-server/src/main/java/org/apache/bookkeeper/client/RackawareEnsemblePlacementPolicy.java:
##########
@@ -110,7 +111,8 @@ public Set<BookieId> onClusterChanged(Set<BookieId>
writableBookies,
Set<BookieId> readOnlyBookies) {
Set<BookieId> deadBookies = super.onClusterChanged(writableBookies,
readOnlyBookies);
if (null != slave) {
- deadBookies = slave.onClusterChanged(writableBookies,
readOnlyBookies);
+ deadBookies = Sets.union(deadBookies,
Review Comment:
`ZoneawareEnsemblePlacementPolicy.onClusterChanged` (lines 76-80, not in
this diff) has the identical structure and still does `deadBookies =
slave.onClusterChanged(...)`, so it keeps the behavior this PR fixes here.
Reproduced with the same sequence as
`testPlacementOnStabilizeNetworkTopology` on the zone-aware policy
(`networkTopologyStabilizePeriodSeconds = 99999`, four bookies, then `addr4`
leaves):
```
assertTrue(deadBookies.contains(addr4.toBookieId()))
-> addr4 left the cluster and must be reported dead: []
```
`TestZoneawareEnsemblePlacementPolicy.testPlacementOnStabilizeNetworkTopology`
still asserts `deadBookies.isEmpty()`, which pins the old result. The only
in-tree caller (`BookieWatcherImpl`) ignores the return value, so I consider
this a nit, but it makes the two policies disagree on the `onClusterChanged`
contract ("the dead bookies during this cluster change"). Suggest applying the
same `Sets.union(...)` there and flipping that test's assertion to
`contains(addr4)`.
##########
bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestRackawareEnsemblePlacementPolicy.java:
##########
@@ -2481,7 +2481,7 @@ public void testPlacementOnStabilizeNetworkTopology()
throws Exception {
// addr4 left
addrs.remove(addr4.toBookieId());
Set<BookieId> deadBookies = repp.onClusterChanged(addrs, new
HashSet<BookieId>());
- assertTrue(deadBookies.isEmpty());
+ assertTrue(deadBookies.contains(addr4.toBookieId()));
Review Comment:
This assertion has teeth against the old code: with the original slave-only
assignment it fails here. But it does not exercise the slave half of the union.
I changed the production code to return only the parent's set
(`slave.onClusterChanged(...)` called, result dropped) and this test, plus the
other Rackaware tests I tried, still passed. In this scenario the slave
returned an empty set when I captured it inside the real call, so the union
cannot be told apart from the parent's result alone.
I could not find a scenario where the slave contributes bookies the parent
does not. If there is one, a test for it would pin the union; if there is none,
the slave call here is only needed for its side effects, which a comment could
say.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]