forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
80132: sql: always return "public" for ResolveSchemaNameByID with ID 29 r=ajwerner a=RichardJCai This allows us to resolve the synthetic public schema in the case where the changefeed is created with a cursor timestamp that is prior to the public schema migration. Release note (bug fix): In 22.1 beta, if the changefeed is created with a cursor time stamp prior to when the public schema migration happened, it would fail to resolve the public schema. This change allows us to resolve the schema. Co-authored-by: richardjcai <[email protected]>
- Loading branch information
Showing
9 changed files
with
86 additions
and
23 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
77 changes: 77 additions & 0 deletions
77
pkg/ccl/changefeedccl/public_schema_migration_changefeed_external_test.go
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 changefeedccl | ||
|
||
import ( | ||
"context" | ||
"net/url" | ||
"testing" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/base" | ||
"github.com/cockroachdb/cockroach/pkg/clusterversion" | ||
"github.com/cockroachdb/cockroach/pkg/jobs" | ||
"github.com/cockroachdb/cockroach/pkg/security" | ||
"github.com/cockroachdb/cockroach/pkg/server" | ||
"github.com/cockroachdb/cockroach/pkg/sql/execinfra" | ||
"github.com/cockroachdb/cockroach/pkg/testutils/sqlutils" | ||
"github.com/cockroachdb/cockroach/pkg/testutils/testcluster" | ||
"github.com/cockroachdb/cockroach/pkg/util/leaktest" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestPublicSchemaMigrationWithCreateChangefeed(t *testing.T) { | ||
defer leaktest.AfterTest(t)() | ||
ctx := context.Background() | ||
|
||
knobs := base.TestingKnobs{ | ||
DistSQL: &execinfra.TestingKnobs{Changefeed: &TestingKnobs{}}, | ||
JobsTestingKnobs: jobs.NewTestingKnobsWithShortIntervals(), | ||
Server: &server.TestingKnobs{ | ||
DisableAutomaticVersionUpgrade: make(chan struct{}), | ||
BinaryVersionOverride: clusterversion.ByKey(clusterversion.PublicSchemasWithDescriptors - 1), | ||
}, | ||
} | ||
|
||
args := base.TestClusterArgs{ | ||
ServerArgs: base.TestServerArgs{ | ||
Knobs: knobs, | ||
}, | ||
} | ||
|
||
tc := testcluster.StartTestCluster(t, 1, args) | ||
defer tc.Stopper().Stop(ctx) | ||
|
||
db := tc.ServerConn(0) | ||
defer db.Close() | ||
s := tc.Server(0) | ||
|
||
sink, cleanup := sqlutils.PGUrl(t, s.ServingSQLAddr(), t.Name(), url.User(security.RootUser)) | ||
defer cleanup() | ||
f := makeTableFeedFactory(s, db, sink) | ||
|
||
tdb := sqlutils.MakeSQLRunner(db) | ||
tdb.Exec(t, `CREATE TABLE defaultdb.public.t();`) | ||
|
||
// Save timestamp pre public schema migration to use for cursor time. | ||
var tsLogical string | ||
tdb.QueryRow(t, `SELECT cluster_logical_timestamp()`).Scan(&tsLogical) | ||
|
||
// Kick off public schema migration. | ||
{ | ||
_, err := tc.Conns[0].ExecContext(ctx, `SET CLUSTER SETTING version = $1`, | ||
clusterversion.ByKey(clusterversion.PublicSchemasWithDescriptors).String()) | ||
require.NoError(t, err) | ||
} | ||
|
||
tdb.Exec(t, `SET CLUSTER SETTING kv.rangefeed.enabled = true;`) | ||
|
||
// Test passes if we can create and close the feed. | ||
out := feed(t, f, `CREATE CHANGEFEED FOR defaultdb.public.t WITH cursor=$1`, tsLogical) | ||
defer closeFeed(t, out) | ||
} |
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
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