-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
server: do not check decommission list for tenants
Previously, the system tenant would return PermissionDenied if the tenant's instance_id was equivalent to a decommissioned node's id. Now, the system tenant does not check the decommissioned node list if the incoming node_id belongs to a non-system tenant. This PR feeds the request context down to the OnOutgoingPing and OnIncomingPing callbacks. Previously the callbacks were using the ambient context. The only use of the context was a storage.MVCCGet call in nodeTombstoneStorage.IsDecommissioned. Release note: None
- Loading branch information
1 parent
ecab739
commit d3ed364
Showing
8 changed files
with
102 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// Copyright 2022 The Cockroach Authors. | ||
// | ||
// Licensed as a CockroachDB Enterprise file under the Cockroach Community | ||
// License (the "License"); you may not use this file except in compliance with | ||
// the License. You may obtain a copy of the License at | ||
// | ||
// https://github.com/cockroachdb/cockroach/blob/master/licenses/CCL.txt | ||
|
||
package serverccl | ||
|
||
import ( | ||
"context" | ||
gosql "database/sql" | ||
"testing" | ||
"time" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/base" | ||
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/liveness/livenesspb" | ||
"github.com/cockroachdb/cockroach/pkg/roachpb" | ||
"github.com/cockroachdb/cockroach/pkg/testutils/serverutils" | ||
"github.com/cockroachdb/cockroach/pkg/testutils/skip" | ||
"github.com/cockroachdb/cockroach/pkg/util/leaktest" | ||
"github.com/cockroachdb/cockroach/pkg/util/log" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestTenantWithDecommissionedID(t *testing.T) { | ||
defer leaktest.AfterTest(t)() | ||
defer log.Scope(t).Close(t) | ||
|
||
// This is a regression test for a multi-tenant bug. Each tenant sql server | ||
// is assigned an InstanceID. The InstanceID corresponds to the id column in | ||
// the system.sql_instances table. The sql process sets rpcContext.NodeID = | ||
// InstanceID and PingRequest.NodeID = rpcContext.NodeID. | ||
// | ||
// When a KV node recieves a ping, it checks the NodeID against a | ||
// decommissioned node tombstone list. Until PR #75766, this caused the KV | ||
// node to reject pings from sql servers. The rejected pings would manifest | ||
// as sql connection timeouts. | ||
|
||
skip.UnderStress(t, "decommissioning times out under stress") | ||
|
||
ctx := context.Background() | ||
tc := serverutils.StartNewTestCluster(t, 4, base.TestClusterArgs{}) | ||
defer tc.Stopper().Stop(ctx) | ||
|
||
server := tc.Server(0) | ||
decommissionID := tc.Server(3).NodeID() | ||
require.NoError(t, server.Decommission(ctx, livenesspb.MembershipStatus_DECOMMISSIONING, []roachpb.NodeID{decommissionID})) | ||
require.NoError(t, server.Decommission(ctx, livenesspb.MembershipStatus_DECOMMISSIONED, []roachpb.NodeID{decommissionID})) | ||
|
||
tenantID := serverutils.TestTenantID() | ||
|
||
var tenantSQLServer serverutils.TestTenantInterface | ||
var tenantDB *gosql.DB | ||
for instanceID := 1; instanceID <= int(decommissionID); instanceID++ { | ||
sqlServer, tenant := serverutils.StartTenant(t, server, base.TestTenantArgs{ | ||
TenantID: tenantID, | ||
Existing: instanceID != 1, | ||
// Set a low heartbeat interval. The first heartbeat succeeds | ||
// because the tenant needs to communicate with the kv node to | ||
// determine its instance id. | ||
RPCHeartbeatInterval: time.Millisecond * 5, | ||
}) | ||
if sqlServer.RPCContext().NodeID.Get() == decommissionID { | ||
tenantSQLServer = sqlServer | ||
tenantDB = tenant | ||
} else { | ||
tenant.Close() | ||
} | ||
} | ||
require.NotNil(t, tenantSQLServer) | ||
defer tenantDB.Close() | ||
|
||
_, err := tenantDB.Exec("CREATE ROLE test_user WITH PASSWORD 'password'") | ||
require.NoError(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters