Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions byteman/4.0/election_counter_leader_favor_node2.btm
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ RULE election counter leader cheat
CLASS org.apache.cassandra.service.StorageProxy
METHOD findSuitableEndpoint
AT EXIT
BIND isthere:boolean = $localEndpoints.contains(org.apache.cassandra.locator.InetAddressAndPort.getByName("127.0.0.2"));
BIND isthere:boolean = $localReplicas.stream().anyMatch(r -> { try { return r.endpoint().equals(org.apache.cassandra.locator.InetAddressAndPort.getByName("127.0.0.2")); } catch (Throwable t) { return false; } });
Copy link
Contributor Author

@smiklosovic smiklosovic Nov 28, 2023

Choose a reason for hiding this comment

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

localEndpoints are called localReplicas in 4.0+ and it is a collection of Replicas, not InetAddress(WithPort)

if isthere
DO
return org.apache.cassandra.locator.InetAddressAndPort.getByName("127.0.0.2");
return localReplicas.stream().filter(lr -> { try { return lr.endpoint().equals(InetAddressAndPort.getByName("127.0.0.2")); } catch (Throwable t) { return null; } }).findFirst().get();
ENDRULE
7 changes: 5 additions & 2 deletions counter_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,11 @@ def test_counter_leader_with_partial_view(self):

# Now stop the node and restart but first install a rule to slow down how fast node 2 will update the list
# nodes that are alive
nodes[1].stop(wait=True, wait_other_notice=False)
nodes[1].update_startup_byteman_script(mk_bman_path('gossip_alive_callback_sleep.btm'))
nodes[1].stop(wait=True, wait_other_notice=True)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is here to tell nodes which are still up that the second node went offline. Without that, it will still think that the second node is up.


if cluster.version() < '5.1':
nodes[1].update_startup_byteman_script(mk_bman_path('gossip_alive_callback_sleep.btm'))

nodes[1].start(no_wait=True, wait_other_notice=False)
Copy link
Contributor Author

@smiklosovic smiklosovic Nov 28, 2023

Choose a reason for hiding this comment

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

here we do not wait for other nodes to notice the second one is up, it will be detected on their own when the logic is correct. Until they see the second node JOINED after we started it, they will never select that on their own.


# Until node 2 is fully alive try to force other nodes to pick him as mutation leader.
Expand Down