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

sql: add missing locking for txnState.mu.txn writes #33249

Merged
merged 1 commit into from
Dec 18, 2018

Conversation

petermattis
Copy link
Collaborator

Fixes #32523

Release note: None

@petermattis petermattis requested review from a team December 18, 2018 20:07
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@petermattis
Copy link
Collaborator Author

Note that I'm still trying to reproduce the original failure, though I'm pretty sure this is the fix.

Copy link
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

// Note that reads of mu.txn from the session's main goroutine do not require
// acquiring a read lock - since only that goroutine will ever write to
// mu.txn.
// mu.txn. Writes to mu.txn do require a write lock to guarantee safety with
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd argue that this comment is not needed, but I guess I've forfeited that right.

@petermattis
Copy link
Collaborator Author

make roachprod-stressrace PKG=./sql/ TESTS=TestIdleCancelSession CLUSTER=peter-stress failed in 1m30s before this PR. Let's see what it does with this PR.

@petermattis
Copy link
Collaborator Author

No reproduction via roachprod-stressrace with this PR. I'll bors once CI finishes.

@petermattis
Copy link
Collaborator Author

bors r=andreimatei

craig bot pushed a commit that referenced this pull request Dec 18, 2018
33193: sql: remove maps from cfetcher hot path r=jordanlewis a=jordanlewis

Closes #32968.

Previously, the cfetcher used a Go map to keep track of the relationship
between column id and column index, so that during decoding of value
columns, it could put the decoded value in the correct spot depending on
its column id. This was fairly expensive and showed up very heavily in
profiles.

This commit changes the approach used, by recognizing that within any
given key/value pair, the encountered column ids will be strictly
increasing. Thanks to this knowledge, it becomes cheap to use a regular
list for storage of the mapping - instead of an O(n) lookup for every
column value in a kv pair, it's O(n) for the whole kv pair, since we can
save our position within the sorted list of required column ids.

This reduces the time spent in the cfetcher's ProcessValueBytes method
from 30% to 10% for a large scan.

Release note: None

33248: diagnosticspb: restore deleted fields r=dt a=dt

We don't actually want to delete fields since older nodes will still be writing them,
and we use the same proto to decode reported diagnostics data so it wants to read those.

Instead we can just prefix them so it is clear they're not used.

Release note: none

33249: sql: add missing locking for txnState.mu.txn writes r=andreimatei a=petermattis

Fixes #32523

Release note: None

Co-authored-by: Jordan Lewis <jordanthelewis@gmail.com>
Co-authored-by: David Taylor <tinystatemachine@gmail.com>
Co-authored-by: Peter Mattis <petermattis@gmail.com>
@craig
Copy link
Contributor

craig bot commented Dec 18, 2018

Build succeeded

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.

3 participants