Skip to content

storage: don't consult TxnSpanGCThreshold when creating txn records#34778

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
nvb:nvanbenschoten/gcReq
Feb 13, 2019
Merged

storage: don't consult TxnSpanGCThreshold when creating txn records#34778
craig[bot] merged 1 commit intocockroachdb:masterfrom
nvb:nvanbenschoten/gcReq

Conversation

@nvb
Copy link
Copy Markdown
Contributor

@nvb nvb commented Feb 11, 2019

Cleanup from #33523.

This commit weakens the semantics of Replica.CanCreateTxnRecord slightly to
allow it to ignore the TxnSpanGCThreshold. CanCreateTxnRecord no longer
consults the TxnSpanGCThreshold, so it doesn't prevent the creation of new
transaction records beneath it. That's ok though, because we still prevent the
recreation of aborted and GCed transaction records, which was the important part
of the check. This protection is now provided by updating the write timestamp
cache on successful TxnPush(ABORT) requests (added in #33523). The GC queue
will always PushTxn(ABORT) transactions if it finds them PENDING, so the
TxnSpanGCThreshold check isn't giving us anything important.

For a visual summary of this change, look at the update to the state machine
diagram in replica_tscache.go.

Migration Safety

In the next release cycle, this change will allow us to remove the
TxnSpanGCThreshold entirely because the protection it was providing is
now entirely handled by the timestamp cache.

In the meantime, we need to keep setting it to ensure that the protection still
works properly on old (v2.1) leaseholders. However, we're safe to no-longer
consult it at all on new (v2.2) leaseholders. This is because even if a new node
is given the lease from an old node that isn't correctly bumping the timestamp
cache on PushTxn requests, we know that the old node will have a clock at
least as large as a txn in question's OrigTimestamp. That means that the new
leaseholder will necessarily bump its write timestamp cache to at least as large
as this txn's OrigTimestamp, so Replica.CanCreateTxnRecord will always fail.

Release note: None

@nvb nvb requested review from a team, andreimatei and tbg February 11, 2019 16:11
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
Member

@tbg tbg left a comment

Choose a reason for hiding this comment

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

Reviewed 13 of 13 files at r1.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @andreimatei)

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.

LGTM
#cleanerEveryday

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @nvanbenschoten)


pkg/roachpb/api.proto, line 679 at r1 (raw file):

  // TxnSpanGCThreshold is the timestamp below which inactive transactions were
  // considered for GC (and thus might have been removed).
  // TODO(nvanbenschoten): Remove this in 2.3, at which point we won't need to

2.3->19.2 everywhere


pkg/roachpb/errors.proto, line 138 at r1 (raw file):

  // got GCed (so, we might be in the ABORT_REASON_ABORTED_RECORD_FOUND case and
  // not know).
  // TODO(nvanbenschoten): Remove this error reason in 2.3, at which point no

2.3->19.2


pkg/storage/replica_tscache.go, line 266 at r1 (raw file):

//    information to transactions who have not yet written their transaction
//    record. In doing so, it protects against transaction records from being
//    created with too low of a timestamp if a PushTxn(TIMESTAMP) has succeeded

I'm very tired today, but it took me a second to parse the difference between "being created with too low of a timestamp" and "being written in the first place".
I ignored the "with too low of a ts" part partially because the one clause uses "created" when another uses "written" and "in the first place" is confusing.

I'd suggest:
s/in the first place/at all
s/being written/being created

and emphasizing that in the PushTxn(ts) case, the txn record will be written with a higher timestamp.

Cleanup from cockroachdb#33523.

This commit weakens the semantics of `Replica.CanCreateTxnRecord` slightly to
allow it to ignore the `TxnSpanGCThreshold`. `CanCreateTxnRecord` no longer
consults the `TxnSpanGCThreshold`, so it doesn't prevent the creation of new
transaction records beneath it. That's ok though, because we still prevent the
recreation of aborted and GCed transaction records, which was the important part
of the check. This protection is now provided by updating the write timestamp
cache on successful `TxnPush(ABORT)` requests (added in cockroachdb#33523). The GC queue
will always `PushTxn(ABORT)` transactions if it finds them `PENDING`, so the
`TxnSpanGCThreshold` check isn't giving us anything important.

For a visual summary of this change, look at the update to the state machine
diagram in `replica_tscache.go`.

_### Migration Safety

In the next release cycle, this change will allow us to remove the
`TxnSpanGCThreshold` entirely because the protection it was providing is
now entirely handled by the timestamp cache.

In the meantime, we need to keep setting it to ensure that the protection still
works properly on old (v2.1) leaseholders. However, we're safe to no-longer
consult it at all on new (v2.2) leaseholders. This is because even if a new node
is given the lease from an old node that isn't correctly bumping the timestamp
cache on `PushTxn` requests, we know that the old node will have a clock at
least as large as a txn in question's OrigTimestamp. That means that the new
leaseholder will necessarily bump its write timestamp cache to at least as large
as this txn's OrigTimestamp, so `Replica.CanCreateTxnRecord` will always fail.

Release note: None
@nvb nvb force-pushed the nvanbenschoten/gcReq branch from e5a7861 to 1bf315d Compare February 13, 2019 21:50
@nvb
Copy link
Copy Markdown
Contributor Author

nvb commented Feb 13, 2019

bors r+

Copy link
Copy Markdown
Contributor Author

@nvb nvb left a comment

Choose a reason for hiding this comment

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

TFTRs.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @andreimatei and @tbg)


pkg/roachpb/api.proto, line 679 at r1 (raw file):

Previously, andreimatei (Andrei Matei) wrote…

2.3->19.2 everywhere

I'll do that all in one go.


pkg/roachpb/errors.proto, line 138 at r1 (raw file):

Previously, andreimatei (Andrei Matei) wrote…

2.3->19.2

Ditto.


pkg/storage/replica_tscache.go, line 266 at r1 (raw file):

Previously, andreimatei (Andrei Matei) wrote…

I'm very tired today, but it took me a second to parse the difference between "being created with too low of a timestamp" and "being written in the first place".
I ignored the "with too low of a ts" part partially because the one clause uses "created" when another uses "written" and "in the first place" is confusing.

I'd suggest:
s/in the first place/at all
s/being written/being created

and emphasizing that in the PushTxn(ts) case, the txn record will be written with a higher timestamp.

Done.

craig bot pushed a commit that referenced this pull request Feb 13, 2019
34778: storage: don't consult TxnSpanGCThreshold when creating txn records r=nvanbenschoten a=nvanbenschoten

Cleanup from #33523.

This commit weakens the semantics of `Replica.CanCreateTxnRecord` slightly to
allow it to ignore the `TxnSpanGCThreshold`. `CanCreateTxnRecord` no longer
consults the `TxnSpanGCThreshold`, so it doesn't prevent the creation of new
transaction records beneath it. That's ok though, because we still prevent the
recreation of aborted and GCed transaction records, which was the important part
of the check. This protection is now provided by updating the write timestamp
cache on successful `TxnPush(ABORT)` requests (added in #33523). The GC queue
will always `PushTxn(ABORT)` transactions if it finds them `PENDING`, so the
`TxnSpanGCThreshold` check isn't giving us anything important.

For a visual summary of this change, look at the update to the state machine
diagram in `replica_tscache.go`.

### Migration Safety

In the next release cycle, this change will allow us to remove the
`TxnSpanGCThreshold` entirely because the protection it was providing is
now entirely handled by the timestamp cache.

In the meantime, we need to keep setting it to ensure that the protection still
works properly on old (v2.1) leaseholders. However, we're safe to no-longer
consult it at all on new (v2.2) leaseholders. This is because even if a new node
is given the lease from an old node that isn't correctly bumping the timestamp
cache on `PushTxn` requests, we know that the old node will have a clock at
least as large as a txn in question's OrigTimestamp. That means that the new
leaseholder will necessarily bump its write timestamp cache to at least as large
as this txn's OrigTimestamp, so `Replica.CanCreateTxnRecord` will always fail.

Release note: None

Co-authored-by: Nathan VanBenschoten <nvanbenschoten@gmail.com>
@craig
Copy link
Copy Markdown
Contributor

craig bot commented Feb 13, 2019

Build succeeded

@craig craig bot merged commit 1bf315d into cockroachdb:master Feb 13, 2019
@nvb nvb deleted the nvanbenschoten/gcReq branch February 15, 2019 04:26
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.

4 participants