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

Incorrect replication strategy calculation in DescribeRing #3745

Closed
Michal-Leszczynski opened this issue Mar 6, 2024 · 0 comments · Fixed by #3718
Closed

Incorrect replication strategy calculation in DescribeRing #3745

Michal-Leszczynski opened this issue Mar 6, 2024 · 0 comments · Fixed by #3718
Assignees
Labels
bug Something isn't working repair

Comments

@Michal-Leszczynski
Copy link
Collaborator

The way in which DescribeRing calculates keyspace replication strategy isn't always correct.

	// Detect replication strategy
	if len(ring.HostDC) == 1 {
		ring.Replication = LocalStrategy
	} else {
		ring.Replication = NetworkTopologyStrategy
		for _, tokens := range dcTokens {
			if tokens != len(resp.Payload) {
				ring.Replication = SimpleStrategy
				break
			}
		}
	}

E.g. this test fails when SimpleStrategy RF is greater than half of the nodes count:

	t.Run("keyspace replication strategy", func(t *testing.T) {
		h := newRepairTestHelper(t, session, defaultConfig())
		ctx, cancel := context.WithCancel(context.Background())
		defer cancel()

		if err := clusterSession.ExecStmt("CREATE KEYSPACE test_rf WITH replication = {'class': 'SimpleStrategy', 'replication_factor' : 4}"); err != nil {
			t.Fatal(err)
		}
		defer dropKeyspace(t, clusterSession, "test_rf")

		ring, err := h.Client.DescribeRing(ctx, "test_rf")
		if err != nil {
			t.Fatal(err)
		}

		t.Log("Replication strategy", ring.Replication)
		if ring.Replication != scyllaclient.SimpleStrategy {
			t.Fatal("Incorrect replication strategy")
		}
	})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working repair
Projects
None yet
1 participant