-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sql/catalog: always clone with the modification timestamp set
Previously, the RunPostDeserializationChanges would always copy descriptors even with our new copy on write semantics. This would happen because the original copy never has the modification or creation timestamps set. To address this, this patch modifies the builder to set these timestamps within the original copy stored inside. Release note: None
- Loading branch information
Showing
7 changed files
with
229 additions
and
156 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
144 changes: 72 additions & 72 deletions
144
pkg/sql/catalog/systemschema_test/testdata/bootstrap_system
Large diffs are not rendered by default.
Oops, something went wrong.
144 changes: 72 additions & 72 deletions
144
pkg/sql/catalog/systemschema_test/testdata/bootstrap_tenant
Large diffs are not rendered by default.
Oops, something went wrong.
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,35 @@ | ||
// Copyright 2024 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package tabledesc_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/sql/catalog/systemschema" | ||
"github.com/cockroachdb/cockroach/pkg/sql/catalog/tabledesc" | ||
"github.com/cockroachdb/cockroach/pkg/util/hlc" | ||
"github.com/cockroachdb/cockroach/pkg/util/timeutil" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
// TestDescriptorsAreNotCopied validate that descriptors that have | ||
// survived post de-serialziation don't have to go through it again. | ||
func TestDescriptorsAreNotCopied(t *testing.T) { | ||
// Sanity: Loop over the system tables and confirm that | ||
// PostDeserialization does zero work on updated descriptors. | ||
for _, targetDesc := range systemschema.MakeSystemTables() { | ||
ts := hlc.Timestamp{WallTime: timeutil.Now().Unix()} | ||
b := tabledesc.NewBuilderWithMVCCTimestamp(targetDesc.TableDesc(), ts) | ||
require.NoError(t, b.RunPostDeserializationChanges()) | ||
require.Falsef(t, b.DescriptorWasModified(), | ||
"%s descriptor was copied again", targetDesc.GetName()) | ||
} | ||
} |