Skip to content

sql,sqlbase,client: bootstrap TableDescriptor timestamps from MVCC#40581

Merged
craig[bot] merged 2 commits intocockroachdb:masterfrom
ajwerner:ajwerner/dont-observe-committimestamp-in-table-desc-updates
Sep 14, 2019
Merged

sql,sqlbase,client: bootstrap TableDescriptor timestamps from MVCC#40581
craig[bot] merged 2 commits intocockroachdb:masterfrom
ajwerner:ajwerner/dont-observe-committimestamp-in-table-desc-updates

Conversation

@ajwerner
Copy link
Copy Markdown
Contributor

@ajwerner ajwerner commented Sep 8, 2019

Using the MVCC timestamp of the value for table descriptors has long been
theorized as the right mechanism to eliminate the need for transactions
which update a table descriptor version to observe their commit timestamp
(see #17698 (comment)).

The challenge was presumed to be the need to expose MVCC timestamps in our
client library. It turns out we seem to do that already (how did nobody know
that?!).

This commit experiments with avoiding using the CommitTimestamp by using the
MVCC timestamp on the read path. It could be cleaned up but seems to work
beautifully. There are still a couple of other places in schema changes which
observe their CommitTimestamp but my sense is this approach will work there
too.

In order to make this setting of the timestamp less of a footgun we add
a (*Descriptor).Table(hlc.Timestamp) method which forces anybody who extracts
a TableDescriptor from a Descriptor to pass in a timestamp which may be
used to set ModificationTime. A linter in the second commit enforces this
proper usage.

The below SQL would always fail before this change and now passes:

CREATE TABLE foo ( k INT PRIMARY KEY );
BEGIN;
DROP TABLE foo;
<wait a while>
COMMIT;

Similarly the TestImportData seems to pass under stressrace with a 5s
kv.closed_timestamp.target_duration.

Release justification: Fixes release blocker #40504 (comment).

Fixes #21800.
References #37083.

Release note (bug fix): Improve table descriptor update protocol to permit long-running schema change transactions to be pushed and succeed rather than always fail.

@ajwerner ajwerner requested a review from thoszhang September 8, 2019 16:18
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@ajwerner ajwerner force-pushed the ajwerner/dont-observe-committimestamp-in-table-desc-updates branch from aae3b2a to a7e31de Compare September 8, 2019 17:07
@ajwerner ajwerner requested a review from a team as a code owner September 8, 2019 17:07
@ajwerner ajwerner force-pushed the ajwerner/dont-observe-committimestamp-in-table-desc-updates branch from a7e31de to 45f543f Compare September 8, 2019 17:10
Copy link
Copy Markdown
Collaborator

@petermattis petermattis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The challenge was presumed to be the need to expose MVCC timestamps in our
client library. It turns out we seem to do that already (how did nobody know
that?!).

<Raises hand sheepishly>, though note that ScanRequest will only return timestamps if the slower KEY_VALUES format is used.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @ajwerner and @lucy-zhang)


pkg/ccl/changefeedccl/table_history.go, line 286 at r1 (raw file):

				}
				if tableDesc := desc.GetTable(); tableDesc != nil {
					tableDesc.MaybeSetModificationTimeFromMVCCTimestamp(ctx, it.UnsafeKey().Timestamp)

How bad is it going to be if you miss one of the places that table descriptors are decoded? I'm wondering if there is anything that could be done to make this less error prone. For example, could we change the signature for desc.GetTable() to pass in a timestamp which would force you to update all of the callers. Seems like there are too many call sites for that, but maybe that sparks a better idea.


pkg/internal/client/db.go, line 34 at r1 (raw file):

type KeyValue struct {
	Key roachpb.Key
	// TODO(ajwerner): figure out why it says timestamp will always be zero

When using ScanFormat.BATCH_RESPONSE, the ScanResponse.BatchResponses field will contain encoded key/value pairs which do not have a timestamp. See enginepb.ScanDecodeKeyValueNoTS. I think the value in GetResponse will always contain a timestamp, though I'm not 100% sure.


pkg/sql/sqlbase/structured.go, line 1509 at r1 (raw file):

	// transaction will commit at the CommitTimestamp().
	//
	// TODO(vivek): Stop needing to do this by deprecating the

You're addressing this TODO in this PR. Is there anything left to do afterwards?


pkg/sql/sqlbase/structured.go, line 3722 at r1 (raw file):

			"its MVCC timestamp: has %v, expected less than %v %+v",
			desc.ModificationTime, ts, desc)
	}

I was expecting desc.ModificationTime to be set to ts if desc.ModificationTime < ts. It took me a moment to understand that desc.ModificationTime.IsEmpty() indicates that the modification time should be set from the MVCC timestamp and any non-empty values means that it was set by MaybeIncrementVersion. I see this is all explained in the comment for ModificationTime, but I just hadn't reached that part of the review yet. Wouldn't hurt to copy some of those words here as well.

@ajwerner ajwerner force-pushed the ajwerner/dont-observe-committimestamp-in-table-desc-updates branch from 45f543f to b36416a Compare September 8, 2019 17:42
Copy link
Copy Markdown
Contributor Author

@ajwerner ajwerner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @lucy-zhang and @petermattis)


pkg/ccl/changefeedccl/table_history.go, line 286 at r1 (raw file):

Previously, petermattis (Peter Mattis) wrote…

How bad is it going to be if you miss one of the places that table descriptors are decoded? I'm wondering if there is anything that could be done to make this less error prone. For example, could we change the signature for desc.GetTable() to pass in a timestamp which would force you to update all of the callers. Seems like there are too many call sites for that, but maybe that sparks a better idea.

It can be pretty bad. I missed the case in ConditionalGetTableDescFromTxn and it made the test fail. That specific method probably doesn't need to decode the table descriptor itself and could probably use one of the helpers from that package.

In an earlier iteration I attempted to rename the proto TableDescriptor to RawTableDescriptor and then have a TableDescriptor type that wraps the RawTableDescriptor to enforce that the modification time was properly updated. That turned out to be pretty heavy and I was making a mess and preventing myself from getting to a place where I could understand if this change works. Maybe it is worth walking down that path.

I don't know to how hard it would be to write a linter that checks if any function unmarshals into a TableDescriptor or Descriptor and then doesn't call MaybeSetModificationTimeFromMVCCTimestamp before returning. I guess now could be a good time to try out https://godoc.org/golang.org/x/tools/go/analysis


pkg/internal/client/db.go, line 34 at r1 (raw file):

Previously, petermattis (Peter Mattis) wrote…

When using ScanFormat.BATCH_RESPONSE, the ScanResponse.BatchResponses field will contain encoded key/value pairs which do not have a timestamp. See enginepb.ScanDecodeKeyValueNoTS. I think the value in GetResponse will always contain a timestamp, though I'm not 100% sure.

Yeah I noticed that. We only ever seem to use that in the KV fetcher here

key, rawBytes, f.batchResponse, err = enginepb.ScanDecodeKeyValueNoTS(f.batchResponse)
and we don't ever fetch these things as sql rows so it should be okay. I'll update the comment to explain when this is zero.
how


pkg/sql/sqlbase/structured.go, line 1509 at r1 (raw file):

Previously, petermattis (Peter Mattis) wrote…

You're addressing this TODO in this PR. Is there anything left to do afterwards?

Nope. Done.


pkg/sql/sqlbase/structured.go, line 3722 at r1 (raw file):

Previously, petermattis (Peter Mattis) wrote…

I was expecting desc.ModificationTime to be set to ts if desc.ModificationTime < ts. It took me a moment to understand that desc.ModificationTime.IsEmpty() indicates that the modification time should be set from the MVCC timestamp and any non-empty values means that it was set by MaybeIncrementVersion. I see this is all explained in the comment for ModificationTime, but I just hadn't reached that part of the review yet. Wouldn't hurt to copy some of those words here as well.

I initially wanted it to be the case that if ModificationTime was non-zero then it would have to be exactly equal to the MVCC timestamp. Unfortunately there are places where we update these descriptors in place without touching the version or modification time (schema leases being the best example). Any time we do that now it will upgrade the descriptor to explicitly knowing about its ModificationTime.

This way ModificationTime will either be zero and we know that it's the first value for this version and its MVCC timestamp can be used or it's non-zero and either it was written by an older version of crdb or we've updated it in place. I've add more commentary.

@ajwerner ajwerner force-pushed the ajwerner/dont-observe-committimestamp-in-table-desc-updates branch 4 times, most recently from 1d27c4c to a6aaf12 Compare September 9, 2019 12:45
Copy link
Copy Markdown
Collaborator

@petermattis petermattis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @ajwerner, @lucy-zhang, and @petermattis)


pkg/ccl/changefeedccl/table_history.go, line 286 at r1 (raw file):

Previously, ajwerner wrote…

It can be pretty bad. I missed the case in ConditionalGetTableDescFromTxn and it made the test fail. That specific method probably doesn't need to decode the table descriptor itself and could probably use one of the helpers from that package.

In an earlier iteration I attempted to rename the proto TableDescriptor to RawTableDescriptor and then have a TableDescriptor type that wraps the RawTableDescriptor to enforce that the modification time was properly updated. That turned out to be pretty heavy and I was making a mess and preventing myself from getting to a place where I could understand if this change works. Maybe it is worth walking down that path.

I don't know to how hard it would be to write a linter that checks if any function unmarshals into a TableDescriptor or Descriptor and then doesn't call MaybeSetModificationTimeFromMVCCTimestamp before returning. I guess now could be a good time to try out https://godoc.org/golang.org/x/tools/go/analysis

Well, there are only 46 callers of GetTable(), perhaps my idea of changing the signature isn't too onerous.


pkg/sql/sqlbase/structured.go, line 3718 at r2 (raw file):

//
// TODO(ajwerner): devise a mechanism to ensure that this method is always
// called when decoding table descriptors.

+1 to the TODO.

@ajwerner ajwerner force-pushed the ajwerner/dont-observe-committimestamp-in-table-desc-updates branch 3 times, most recently from c10e6e4 to c5d1434 Compare September 11, 2019 15:17
@ajwerner ajwerner changed the title [DNM] sql,sqlbase,client: bootstrap TableDescriptor.ModficationTime from MVCC ts sql,sqlbase,client: bootstrap TableDescriptor.ModficationTime from MVCC ts Sep 11, 2019
Copy link
Copy Markdown
Contributor Author

@ajwerner ajwerner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a new accessor method for the TableDescriptor which takes a timestamp and validates it. There's a heavy linter too, I wanted to make it do more but alas. RFAL.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @ajwerner, @lucy-zhang, and @petermattis)


pkg/ccl/backupccl/backup.go, line 307 at r4 (raw file):

				"%s: unable to unmarshal SQL descriptor", row.Key)
		}
		if row.Value != nil {

This is the case I'd love a linter to catch but I suspect we'd find it with the assert when the timestamp wasn't set and the caller didn't have a reasonable timestamp.


pkg/ccl/changefeedccl/table_history.go, line 286 at r1 (raw file):

Previously, petermattis (Peter Mattis) wrote…

Well, there are only 46 callers of GetTable(), perhaps my idea of changing the signature isn't too onerous.

GetTable() is generated. I added Table() that works this way and a linter to avoid calls of GetTable(). The linter was written in a way too heavy-weight way, I'm sure that something like the grep used in TestTimeutil could have worked. I had grander visions of detecting unmarshaling and requiring a call to Table().


pkg/internal/client/db.go, line 34 at r1 (raw file):

Previously, ajwerner wrote…

Yeah I noticed that. We only ever seem to use that in the KV fetcher here

key, rawBytes, f.batchResponse, err = enginepb.ScanDecodeKeyValueNoTS(f.batchResponse)
and we don't ever fetch these things as sql rows so it should be okay. I'll update the comment to explain when this is zero.
how

Done.

@ajwerner
Copy link
Copy Markdown
Contributor Author

I'm extending this first commit to follow the same pattern for CreateAsOfTime.

@ajwerner ajwerner force-pushed the ajwerner/dont-observe-committimestamp-in-table-desc-updates branch 2 times, most recently from 9fe4187 to 75f52a3 Compare September 11, 2019 17:42
Copy link
Copy Markdown

@thoszhang thoszhang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't look at the new linter closely.

Reviewed 1 of 13 files at r1, 2 of 13 files at r2, 23 of 28 files at r3, 12 of 17 files at r5, 2 of 8 files at r7, 1 of 5 files at r8.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @ajwerner, @BramGruneir, @lucy-zhang, and @petermattis)


pkg/ccl/backupccl/restore.go, line 48 at r6 (raw file):

	"github.com/cockroachdb/cockroach/pkg/util/tracing"
	"github.com/cockroachdb/errors"
	opentracing "github.com/opentracing/opentracing-go"

nit: Is this intentional?


pkg/sql/conn_executor_exec.go, line 489 at r8 (raw file):

	// with:
	//
	//  1. Leases at version V-2 for a descriptor being modified to version

I think this sentence got slightly mangled.


pkg/sql/conn_executor_exec.go, line 507 at r8 (raw file):

	{
		// If there are existing leases at V-2 for a descriptor being modified at
		// version V being help, the wait loop below that waits on a cluster wide

held


pkg/sql/conn_executor_exec.go, line 536 at r8 (raw file):

				filteredLeases = append(filteredLeases, l)
			} else if err := ex.planner.LeaseMgr().Release(l); err != nil {
				log.Warning(ctx, err)

What happens if we fail to release the lease here? Does it get caught in CountLeases and cause a retry? Do we wait somewhere else until it expires?


pkg/sql/logictest/testdata/logic_test/schema_change_retry, line 3 at r8 (raw file):

# This test reproduces https://github.com/cockroachdb/cockroach/issues/23979

# Schema changes that experienced retriable errors in RELEASE

nit: This comment should be updated

@ajwerner ajwerner force-pushed the ajwerner/dont-observe-committimestamp-in-table-desc-updates branch from 75f52a3 to 474d9d2 Compare September 11, 2019 19:23
Copy link
Copy Markdown

@thoszhang thoszhang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just saw some test failures in teamcity related to the foreign key upgrade.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @ajwerner, @BramGruneir, @lucy-zhang, and @petermattis)


pkg/sql/logictest/testdata/logic_test/schema_change_retry, line 1 at r7 (raw file):

# This test reproduces https://github.com/cockroachdb/cockroach/issues/23979

I just saw the test failure under local-mixed-19.1-19.2. I think this test just shouldn't run with that config (which simulates a cluster running a 19.2 binary where the cluster version is an earlier version, introduced during the FK table desc upgrade), since the behavior is actually different between the cluster versions.

# LogicTest: local fakedist fakedist-metadata fakedist-disk is the config we use for schema_change_in_txn and should be fine for this too. If you think it's important to also run this test in local-mixed-19.1-19.2, the solution we came up with was to have a separate file that only runs in that config (e.g., schema_change_in_txn-local-mixed-19.1-19.2).


pkg/sql/sqlbase/structured.go, line 797 at r10 (raw file):

	ctx context.Context, key interface{}, msg protoutil.Message,
) (hlc.Timestamp, error) {
	return hlc.Timestamp{}, m.getProto(ctx, key, msg)

I think the TestUpgradeDowngradeFKRepr panic is caused by this function not returning a valid timestamp and the test itself having table descriptors that don't have the ModificationTime set. The more realistic test would be to somehow have this method return a valid timestamp, but an easier fix would be to set the ModificationTimes.

@ajwerner ajwerner force-pushed the ajwerner/dont-observe-committimestamp-in-table-desc-updates branch 2 times, most recently from 2bb31ce to 87a5447 Compare September 11, 2019 22:08
Copy link
Copy Markdown
Contributor Author

@ajwerner ajwerner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just saw some test failures in teamcity related to the foreign key upgrade.

fixed.

This should be close. @andreimatei let me know if you want to take a look.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @BramGruneir, @lucy-zhang, and @petermattis)


pkg/sql/conn_executor_exec.go, line 489 at r8 (raw file):

Previously, lucy-zhang (Lucy Zhang) wrote…

I think this sentence got slightly mangled.

Done.


pkg/sql/conn_executor_exec.go, line 507 at r8 (raw file):

Previously, lucy-zhang (Lucy Zhang) wrote…

held

Done.


pkg/sql/conn_executor_exec.go, line 536 at r8 (raw file):

Previously, lucy-zhang (Lucy Zhang) wrote…

What happens if we fail to release the lease here? Does it get caught in CountLeases and cause a retry? Do we wait somewhere else until it expires?

It's not clear to me why it would fail or what it would mean. This is what the logic under releaseLeases did before so it can't be worse than that. My guess is yes, if it fails we'll fail and then wait for them to expire in the loop below. The error could be an ambiguous result so we may as well proceed to the check below.


pkg/sql/logictest/testdata/logic_test/schema_change_retry, line 1 at r7 (raw file):

Previously, lucy-zhang (Lucy Zhang) wrote…

I just saw the test failure under local-mixed-19.1-19.2. I think this test just shouldn't run with that config (which simulates a cluster running a 19.2 binary where the cluster version is an earlier version, introduced during the FK table desc upgrade), since the behavior is actually different between the cluster versions.

# LogicTest: local fakedist fakedist-metadata fakedist-disk is the config we use for schema_change_in_txn and should be fine for this too. If you think it's important to also run this test in local-mixed-19.1-19.2, the solution we came up with was to have a separate file that only runs in that config (e.g., schema_change_in_txn-local-mixed-19.1-19.2).

So I modified this test because it didn't really make sense anymore. I don't have strong feeling about it. I've added the annotation you suggested.

I need to work harder to create a serializable retry. For now to make sure that the tests pass I'm removing this but I can add it back when fixed with the actual retry after. I just want to get this review into a reasonable state before I head out this evening.


pkg/sql/logictest/testdata/logic_test/schema_change_retry, line 3 at r8 (raw file):

Previously, lucy-zhang (Lucy Zhang) wrote…

nit: This comment should be updated

Sure, but what should it say.


pkg/sql/sqlbase/structured.go, line 3718 at r2 (raw file):

Previously, petermattis (Peter Mattis) wrote…

+1 to the TODO.

Done.


pkg/sql/sqlbase/structured.go, line 797 at r10 (raw file):

Previously, lucy-zhang (Lucy Zhang) wrote…

I think the TestUpgradeDowngradeFKRepr panic is caused by this function not returning a valid timestamp and the test itself having table descriptors that don't have the ModificationTime set. The more realistic test would be to somehow have this method return a valid timestamp, but an easier fix would be to set the ModificationTimes.

Done.

Copy link
Copy Markdown
Contributor

@andreimatei andreimatei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @ajwerner, @BramGruneir, @lucy-zhang, and @petermattis)


pkg/internal/client/db.go, line 338 at r11 (raw file):

func (db *DB) GetProtoTs(
	ctx context.Context, key interface{}, msg protoutil.Message,
) (ts hlc.Timestamp, err error) {

nit: get rid of the names on the return values. They don't add anything. And they invite a nit on the return ts, err line about how it should be return hlc.Timestamp{}, err


pkg/sql/conn_executor_exec.go, line 477 at r11 (raw file):

// proceed.
func (ex *connExecutor) checkTableTwoVersionInvariant(ctx context.Context) error {
	tables := ex.extraTxnState.tables.getTablesWithNewVersion()

nit: move this tables below the big comments


pkg/sql/conn_executor_exec.go, line 490 at r11 (raw file):

	//
	//  1. Leases at version V-2 for a descriptor being modified to version V.
	//  These leases must be dropped immediately because we're going to assert

nit: we're not going to "assert" anything, we're going to "check" something. Saying assert seems to contradict the next sentence.


pkg/sql/conn_executor_exec.go, line 505 at r11 (raw file):

	// cases explicitly. We must release the 1. leases above before we attempt
	// to check the invariant, otherwise it's doomed to fail.
	// the other leases we need to wait until we commit to release.

s/the/The


pkg/sql/conn_executor_exec.go, line 512 at r11 (raw file):

		// version V being held, the wait loop below that waits on a cluster wide
		// release of old version leases will hang until these leases expire so
		// we need to drop these leases right now. It is not safe to release leases

can you expand on this "it is not safe to release..."? I assume it has to do with the fact that the current txn might have used them. But how come we're sure it hasn't used the v-2 ones? I believe that's probably true, but I'd like to see the argument.

And actually... Are you sure we can't release the V-1 ones too? What's the hazard? The hazard, I guess, is that this transaction would then be free to commit at a timestamp above the lease (which generally is not allowed because that might be outside of V-1's validity). But, if the transaction commits, it is writing V (or perhaps another transaction will write V, but definitely at a timestamp above the commit ts). So then, I think it is in fact safe to commit the current transaction, because we know that V-1's validity is being extended.

I don't know what I'm talking about, although I'm probably "the expert" on this stuff. But it's been a while and you seem to have done your homework, so perhaps you can school me.

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Sep 13, 2019

Build failed

@ajwerner
Copy link
Copy Markdown
Contributor Author

Needed a release justification in the description.

bors r+

craig bot pushed a commit that referenced this pull request Sep 14, 2019
40581: sql,sqlbase,client: bootstrap TableDescriptor timestamps from MVCC r=ajwerner a=ajwerner

Using the MVCC timestamp of the value for table descriptors has long been
theorized as the right mechanism to eliminate the need for transactions
which update a table descriptor version to observe their commit timestamp
(see #17698 (comment)).

The challenge was presumed to be the need to expose MVCC timestamps in our
client library. It turns out we seem to do that already (how did nobody know
that?!).

This commit experiments with avoiding using the CommitTimestamp by using the
MVCC timestamp on the read path. It could be cleaned up but seems to work
beautifully. There are still a couple of other places in schema changes which
observe their CommitTimestamp but my sense is this approach will work there
too.

In order to make this setting of the timestamp less of a footgun we add
a `(*Descriptor).Table(hlc.Timestamp)` method which forces anybody who extracts
a `TableDescriptor` from a `Descriptor` to pass in a timestamp which may be
used to set `ModificationTime`. A linter in the second commit enforces this
proper usage.

The below SQL would always fail before this change and now passes:

```
CREATE TABLE foo ( k INT PRIMARY KEY );
BEGIN;
DROP TABLE foo;
<wait a while>
COMMIT;
```

Similarly the TestImportData seems to pass under stressrace with a 5s
`kv.closed_timestamp.target_duration`.

Release justification: Fixes release blocker #40504 (comment).

Fixes #21800.
References #37083.

Release note (bug fix): Improve table descriptor update protocol to permit long-running schema change transactions to be pushed and succeed rather than always fail. 

Co-authored-by: Andrew Werner <ajwerner@cockroachlabs.com>
@craig
Copy link
Copy Markdown
Contributor

craig bot commented Sep 14, 2019

Build succeeded

@craig craig bot merged commit 2bf4c57 into cockroachdb:master Sep 14, 2019
craig bot pushed a commit that referenced this pull request Sep 16, 2019
40781: sql,sqlbase,client: revert #40581 r=jordanlewis a=jordanlewis

It was buggy in presence of pre 19.1 backups; reverting until @ajwerner has a chance to fix and add tests.

Co-authored-by: Jordan Lewis <jordanthelewis@gmail.com>
craig bot pushed a commit that referenced this pull request Sep 16, 2019
40781: sql,sqlbase,client: revert #40581 r=jordanlewis a=jordanlewis

It was buggy in presence of pre 19.1 backups; reverting until @ajwerner has a chance to fix and add tests.

Release justification: reverts a buggy patch

Co-authored-by: Jordan Lewis <jordanthelewis@gmail.com>
craig bot pushed a commit that referenced this pull request Sep 17, 2019
40793: sql,sqlbase,client: bootstrap TableDescriptor timestamps from MVCC r=ajwerner a=ajwerner

This PR adds back the changes in #40581 and deals with the fallout that led to #40781 in the 3rd commit.

Release Justification: Fixes a bug formerly considered to be a release blocker. 


Co-authored-by: Andrew Werner <ajwerner@cockroachlabs.com>
ajwerner pushed a commit to ajwerner/cockroach that referenced this pull request Nov 21, 2019
…escriptors

In cockroachdb#40581 we changed the protocol for creating and updating table descriptors
to no longer serialize the hlc timestamp at which the descriptor was created
or modified directly into the value but rather to infer it from the MVCC
timestamp of the row. For backwards compatibility we left a migration in
place. This commit finishes the migration.

Release note: None.
ajwerner pushed a commit to ajwerner/cockroach that referenced this pull request Nov 25, 2019
In cockroachdb#40581 we stopped observing the commit timestamp to write it into table
descriptors. In this change I overlooked (rather forgot) about this additional
place in the code where we observed the commit timestamp. As far as I can tell
we don't read this field anywhere ever. Furthermore we know that the the table
descriptor in question to which we are referring must be alive and equal to
the provided value at the timestamp at which it was read due to
serializability. In short, this minor change continues to populate the field
with a sensible value and will permit TRUNCATE to be pushed.

Fixes cockroachdb#41566.

Release note (bug fix): Long running transactions which attempt to TRUNCATE
can now be pushed and will commit in cases where they previously could fail
or retry forever.
craig bot pushed a commit that referenced this pull request Nov 25, 2019
42650: sql: stop observing the CommitTimestamp in TRUNCATE r=ajwerner a=ajwerner

In #40581 we stopped observing the commit timestamp to write it into table
descriptors. In this change I overlooked (rather forgot) about this additional
place in the code where we observed the commit timestamp. As far as I can tell
we don't read this field anywhere ever. Furthermore we know that the the table
descriptor in question to which we are referring must be alive and equal to
the provided value at the timestamp at which it was read due to serializability.
In short, this minor change continues to populate the field with a sensible
value and will permit TRUNCATE to be pushed.

Fixes #41566.

Release note (bug fix): Long running transactions which attempt to TRUNCATE
can now be pushed and will commit in cases where they previously could fail
or retry forever.

42746: roachtest/cdc: fix cdc/bank and cdc/schemareg r=nvanbenschoten a=nvanbenschoten

Fixes #41177.
Fixes #42690.

These were both broken by #41793 because prior versions of crdb didn't support the `WITH diff` option.

Co-authored-by: Andrew Werner <ajwerner@cockroachlabs.com>
Co-authored-by: Nathan VanBenschoten <nvanbenschoten@gmail.com>
ajwerner pushed a commit to ajwerner/cockroach that referenced this pull request Nov 26, 2019
In cockroachdb#40581 we stopped observing the commit timestamp to write it into table
descriptors. In this change I overlooked (rather forgot) about this additional
place in the code where we observed the commit timestamp. As far as I can tell
we don't read this field anywhere ever. Furthermore we know that the the table
descriptor in question to which we are referring must be alive and equal to
the provided value at the timestamp at which it was read due to
serializability. In short, this minor change continues to populate the field
with a sensible value and will permit TRUNCATE to be pushed.

Fixes cockroachdb#41566.

Release note (bug fix): Long running transactions which attempt to TRUNCATE
can now be pushed and will commit in cases where they previously could fail
or retry forever.
ajwerner pushed a commit to ajwerner/cockroach that referenced this pull request Jul 1, 2020
…escriptors

In cockroachdb#40581 we changed the protocol for creating and updating table descriptors
to no longer serialize the hlc timestamp at which the descriptor was created
or modified directly into the value but rather to infer it from the MVCC
timestamp of the row. For backwards compatibility we left a migration in
place. This commit finishes the migration.

Release note: None.
craig bot pushed a commit that referenced this pull request Jul 1, 2020
42655: sql,sqlbase: finish the migration to use MVCC timestamps with table descriptors r=ajwerner a=ajwerner

In #40581 we changed the protocol for creating and updating table descriptors
to no longer serialize the hlc timestamp at which the descriptor was created
or modified directly into the value but rather to infer it from the MVCC
timestamp of the row. For backwards compatibility we left a migration in
place. This commit finishes the migration.

Release note: None.

50514: sql: handle deletes for partial indexes r=RaduBerinde a=mgartner

This commit makes `DELETE`s only attempt to remove entries from partial
indexes when the row exists in the partial index. For `DELETE`s, the
optimizer now synthesizes a boolean column for each partial index on the
table. This column evaluates to true if the partial index predicate
evaluates to true for the row being deleted, signifying that it exists
within the partial index and should be deleted.

There are now two sets of columns synthesized for partial index
mutations, PUT columns and DEL columns. The PUT columns communicate when
rows should be added to partial indexes. These are currently used by
`INSERT` and in the future will be used by `UPDATE` and `UPSERT`. The
DEL columns communicate when rows shold be removed from partial indexes.
These are currently used by `DELETE`, and in the future will be used by
`UPDATE` and `UPSERT`.

Release note: None

50546: add zero padding, insert order, and time stamp in text r=robert-s-lee a=robert-s-lee

`--insert-hash=true` creates `user1`, `user2` for `ycsb_key`
`--zero-padding=2` creates `user01`, `user02` for `ycsb_key`
`--time-string=true` creates `field[0-9]` with

```
2020-06-23 13:23:58.529711+00:00DwYFKxzTOKqgYwdHZNmbzdkRfINphVojmwiDbhaFsEnFHRpxSJQdSRnXOrQbjJhjYzko
```
instead of
```
rmArXhKIjbpTAPwyjDNsmkGTLXWNQHQCLAyKwWFOrlopXliOKqQANpakAxsmqfPzYSvAhgYYVQQDhUEuXCVuvsEdJrrguNSaXDbx
```

Closes #50545 and #50544 

Co-authored-by: Andrew Werner <ajwerner@cockroachlabs.com>
Co-authored-by: Marcus Gartner <marcus@cockroachlabs.com>
Co-authored-by: Robert S Lee <sangkyulee@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sql: transaction with schema change gets pushed consistently

5 participants