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

sql: run show cluster setting in a restartable txn #30721

Merged
merged 1 commit into from Oct 11, 2018

Conversation

Projects
None yet
5 participants
@jordanlewis
Member

jordanlewis commented Sep 27, 2018

Previously, SHOW CLUSTER SETTING would run in the parent txn. This was
troublesome because if it misses a KV update once (due to an older txn
timestamp), it'll miss it in perpetuity.

Now, we make a fresh transaction for the kv read, and allow it to
restart.

Closes #30225.

Release note: None

@jordanlewis jordanlewis requested a review from tschottdorf Sep 27, 2018

@jordanlewis jordanlewis requested review from cockroachdb/sql-execution-prs as code owners Sep 27, 2018

@cockroach-teamcity

This comment has been minimized.

Show comment
Hide comment
@cockroach-teamcity

cockroach-teamcity Sep 27, 2018

Member

This change is Reviewable

Member

cockroach-teamcity commented Sep 27, 2018

This change is Reviewable

@jordanlewis

This comment has been minimized.

Show comment
Hide comment
@jordanlewis

jordanlewis Sep 27, 2018

Member

This is extremely science dog, but in principle I don't see any reason why it's not ok to make a new transaction here. The analogous SET CLUSTER SETTING code does it, for example.

Member

jordanlewis commented Sep 27, 2018

This is extremely science dog, but in principle I don't see any reason why it's not ok to make a new transaction here. The analogous SET CLUSTER SETTING code does it, for example.

@tschottdorf

LGTM, but equally 👩‍🔬 🐕 as well, so let's get someone who would know... @andreimatei?

Reviewed 1 of 1 files at r1, 1 of 1 files at r2.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained

@jordanlewis jordanlewis requested a review from andreimatei Sep 27, 2018

@andreimatei

well so this patch introduces non-repeatable reads for transactions that call this showStateMachineSetting(). I'm not sure if it's a good idea (but I haven't checked how this function is used).
Why would we do this , exactly? Skimming through #30225, I understand that the problem is with a set statement. Can't we have that guy create new transactions for every iteration of its polling? (and also probably make that particular set statement illegal inside transactions?)

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained

@jordanlewis

This comment has been minimized.

Show comment
Hide comment
@jordanlewis

jordanlewis Sep 27, 2018

Member

Andrei, I think the problem is only in SHOW, not in SET.

Member

jordanlewis commented Sep 27, 2018

Andrei, I think the problem is only in SHOW, not in SET.

@andreimatei

This comment has been minimized.

Show comment
Hide comment
@andreimatei

andreimatei Sep 27, 2018

Member

Then can you describe the problem, please? :)

Member

andreimatei commented Sep 27, 2018

Then can you describe the problem, please? :)

@jordanlewis

This comment has been minimized.

Show comment
Hide comment
@jordanlewis

jordanlewis Sep 27, 2018

Member

Gossip can win against KV. If the two disagree, you need to restart your txn and check KV again. I think. Honestly, I'm not sure how these components interact exactly.

Member

jordanlewis commented Sep 27, 2018

Gossip can win against KV. If the two disagree, you need to restart your txn and check KV again. I think. Honestly, I'm not sure how these components interact exactly.

@andreimatei

This comment has been minimized.

Show comment
Hide comment
@andreimatei

andreimatei Sep 27, 2018

Member

OK, so this is about show cluster setting version. I think you want to make this statement non-transactional (i.e. make it error out if it's ran inside an explicit txn). In fact, I think we should make all show cluster setting statements non-transactional. Then this change looks fine to me (modulo the fact that I think it's missing the retries).

Member

andreimatei commented Sep 27, 2018

OK, so this is about show cluster setting version. I think you want to make this statement non-transactional (i.e. make it error out if it's ran inside an explicit txn). In fact, I think we should make all show cluster setting statements non-transactional. Then this change looks fine to me (modulo the fact that I think it's missing the retries).

@jordanlewis

This comment has been minimized.

Show comment
Hide comment
@jordanlewis

jordanlewis Sep 27, 2018

Member

What do you mean you think it's missing the retries?

Member

jordanlewis commented Sep 27, 2018

What do you mean you think it's missing the retries?

@andreimatei

See my comment below

we used to retry on this, now we don't. Shouldn't we?

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained


pkg/sql/show_cluster_setting.go, line 86 at r2 (raw file):

		}
		if !bytes.Equal(gossipRawVal, kvRawVal) {
			return errors.Errorf("value differs between gossip (%v) and KV (%v); try again later (%v after %s)", gossipObj, kvObj, retryCtx.Err(), timeutil.Since(tBegin))

we used to retry on this, now we don't. Shouldn't we?

@jordanlewis

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained


pkg/sql/show_cluster_setting.go, line 86 at r2 (raw file):

Previously, andreimatei (Andrei Matei) wrote…

we used to retry on this, now we don't. Shouldn't we?

Yes I suppose we should. Is the right way to do that to keep the outer Retry that I deleted and embed this Txn call within? Also, I don't understand what the last WithMaxAttempts was for - it seems to have been set to MaxInt32 retries.

@jordanlewis

This comment has been minimized.

Show comment
Hide comment
@jordanlewis
Member

jordanlewis commented Oct 11, 2018

@andreimatei

LGTM

But what did you think about disallowing show cluster setting in a txn?

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained


pkg/sql/show_cluster_setting.go, line 23 at r3 (raw file):

	"strings"
	"time"

extra line

sql: run show cluster setting in a restartable txn
Previously, SHOW CLUSTER SETTING would run in the parent txn. This was
troublesome because if it misses a KV update once (due to an older txn
timestamp), it'll miss it in perpetuity.

Now, we make a fresh transaction for the kv read, and allow it to
restart.

Release note: None
@jordanlewis

This comment has been minimized.

Show comment
Hide comment
@jordanlewis

jordanlewis Oct 11, 2018

Member

But what did you think about disallowing show cluster setting in a txn?

What's the point? I guess to just prevent people from being confused? If we're doing this, I think we should do them all at once - and if that's the case, not in this PR.

Member

jordanlewis commented Oct 11, 2018

But what did you think about disallowing show cluster setting in a txn?

What's the point? I guess to just prevent people from being confused? If we're doing this, I think we should do them all at once - and if that's the case, not in this PR.

@jordanlewis

This comment has been minimized.

Show comment
Hide comment
@jordanlewis

jordanlewis Oct 11, 2018

Member

TFTR!

Member

jordanlewis commented Oct 11, 2018

TFTR!

@jordanlewis

This comment has been minimized.

Show comment
Hide comment
@jordanlewis

jordanlewis Oct 11, 2018

Member

bors r+

Member

jordanlewis commented Oct 11, 2018

bors r+

craig bot pushed a commit that referenced this pull request Oct 11, 2018

Merge #30721
30721: sql: run show cluster setting in a restartable txn r=jordanlewis a=jordanlewis

Previously, SHOW CLUSTER SETTING would run in the parent txn. This was
troublesome because if it misses a KV update once (due to an older txn
timestamp), it'll miss it in perpetuity.

Now, we make a fresh transaction for the kv read, and allow it to
restart.

Closes #30225.

Release note: None

Co-authored-by: Jordan Lewis <jordanthelewis@gmail.com>
@andreimatei

This comment has been minimized.

Show comment
Hide comment
@andreimatei

andreimatei Oct 11, 2018

Member

The point is that this patch has made show cluster setting non-transactional, as in non-repeatable read anomaly. Isn't that a biggie?

Member

andreimatei commented Oct 11, 2018

The point is that this patch has made show cluster setting non-transactional, as in non-repeatable read anomaly. Isn't that a biggie?

@jordanlewis

This comment has been minimized.

Show comment
Hide comment
@jordanlewis

jordanlewis Oct 11, 2018

Member

Doesn't feel like a biggie to me. We have other things like that, such as schema changes, don't we?

Member

jordanlewis commented Oct 11, 2018

Doesn't feel like a biggie to me. We have other things like that, such as schema changes, don't we?

@andreimatei

This comment has been minimized.

Show comment
Hide comment
@andreimatei

andreimatei Oct 11, 2018

Member

Schema changes are special beasts indeed, but I don't quite see the analogy. The atomicity of schema changes is questionable, leading to write-skew type anomalies, but that's different (even schema changes outside of txns would have that problem).

Member

andreimatei commented Oct 11, 2018

Schema changes are special beasts indeed, but I don't quite see the analogy. The atomicity of schema changes is questionable, leading to write-skew type anomalies, but that's different (even schema changes outside of txns would have that problem).

@craig

This comment has been minimized.

Show comment
Hide comment
@craig

craig bot commented Oct 11, 2018

Build succeeded

@craig craig bot merged commit 90568da into cockroachdb:master Oct 11, 2018

3 checks passed

GitHub CI (Cockroach) TeamCity build finished
Details
bors Build succeeded
Details
license/cla Contributor License Agreement is signed.
Details

@jordanlewis jordanlewis deleted the jordanlewis:restart-show-cluster-setting-txm branch Oct 12, 2018

@knz

This comment has been minimized.

Show comment
Hide comment
@knz

knz Oct 12, 2018

Member

this needs a backport if you claim it fixes #28879.

Member

knz commented Oct 12, 2018

this needs a backport if you claim it fixes #28879.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment