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

release-19.2: sql: stop observing the CommitTimestamp in TRUNCATE #42772

Merged
merged 1 commit into from
Nov 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 42 additions & 36 deletions pkg/sql/sqlbase/structured.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions pkg/sql/sqlbase/structured.proto
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,12 @@ message TableDescriptor {
message Replacement {
option (gogoproto.equal) = true;
optional uint32 id = 1 [(gogoproto.nullable) = false, (gogoproto.customname) = "ID", (gogoproto.casttype) = "ID"];
// Time is just used for debugging purposes. It is not used in business
// logic. It is an HLC rather than just wall time only for historical
// reasons. Prior to 19.2.2 it was populated with the commit timestamp of
// the transaction which created this replacement. In 19.2.2 and after it is
// populated with the read timestamp at which the descriptor being
// replaced was read.
optional util.hlc.Timestamp time = 2 [(gogoproto.nullable) = false];
}

Expand Down
5 changes: 4 additions & 1 deletion pkg/sql/truncate.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,10 @@ func (p *planner) truncateTable(
tableDesc.DropJobID = dropJobID
newTableDesc := sqlbase.NewMutableCreatedTableDescriptor(tableDesc.TableDescriptor)
newTableDesc.ReplacementOf = sqlbase.TableDescriptor_Replacement{
ID: id, Time: p.txn.CommitTimestamp(),
ID: id,
// NB: Time is just used for debugging purposes. See the comment on the
// field for more details.
Time: p.txn.OrigTimestamp(),
}
newTableDesc.SetID(0)
newTableDesc.Version = 1
Expand Down