Skip to content

Commit

Permalink
migrations: Fix migration discrepancy on a system table.
Browse files Browse the repository at this point in the history
Previously, the migration code for system table
`statement_diagnostics_requests` results in discrepancies when compared
to the table definition after bootstrapping. The discrepanies are
summarized in cockroachdb#77980.

This PR fixes it to ensure this table has exactly the same definition
after cluster upgrading as that from bootstrapping.

Release note (bug fix): Ensure the migration logic for
`system.statement_diagnostics_requests` results in a table definition
that is identical to that from bootstrapping.

Fixes: cockroachdb#77980

Sister Issue: cockroachdb#78302
  • Loading branch information
Xiang-Gu committed Mar 28, 2022
1 parent c1e089d commit 6882378
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ import (
const (
addColsToStmtDiagReqs = `
ALTER TABLE system.statement_diagnostics_requests
ADD COLUMN min_execution_latency INTERVAL NULL,
ADD COLUMN expires_at TIMESTAMPTZ NULL`
ADD COLUMN min_execution_latency INTERVAL NULL FAMILY "primary",
ADD COLUMN expires_at TIMESTAMPTZ NULL FAMILY "primary"`

createCompletedIdxV2 = `
CREATE INDEX completed_idx_v2 ON system.statement_diagnostics_requests (completed, ID)
STORING (statement_fingerprint, min_execution_latency, expires_at)`

dropCompletedIdx = `DROP INDEX IF EXISTS completed_idx`
dropCompletedIdx = `DROP INDEX IF EXISTS system.statement_diagnostics_requests@completed_idx`
)

// alterSystemStmtDiagReqs changes the schema of the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func TestAlterSystemStmtDiagReqs(t *testing.T) {
validationSchemas = []migrations.Schema{
{Name: "min_execution_latency", ValidationFn: migrations.HasColumn},
{Name: "expires_at", ValidationFn: migrations.HasColumn},
{Name: "primary", ValidationFn: migrations.HasColumnFamily},
}
)

Expand Down

0 comments on commit 6882378

Please sign in to comment.