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: fix lease interaction with offline tables #40996

Merged
merged 1 commit into from
Sep 23, 2019

Conversation

pbardea
Copy link
Contributor

@pbardea pbardea commented Sep 23, 2019

This updates the lease management code to handle offline tables the
same way dropped tables are handled. We are not supposed to be able
to acquire a lease on offline tables (as well as dropped tables).

Fixes #40951 and therefore #40361.

Release justification: Fixes test flakes where a table descriptor lease
is being taken on an offline table.

Release note: None

@pbardea pbardea requested a review from dt September 23, 2019 21:10
@cockroach-teamcity
Copy link
Member

This change is Reviewable

This updates the lease management code to handle offline tables the
same way dropped tables are handled. We are not supposed to be able
to acquire a lease on offline tables (as well as dropped tables).

Release justification: Fixes test flakes where a table descriptor lease
is being taken on an offline table.

Release note: None
@@ -284,7 +288,7 @@ func (tc *TableCollection) getTableVersion(
// Read the descriptor from the store in the face of some specific errors
// because of a known limitation of AcquireByName. See the known
// limitations of AcquireByName for details.
if err == errTableDropped || err == sqlbase.ErrDescriptorNotFound {
Copy link
Member

Choose a reason for hiding this comment

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

nice catch!

@pbardea
Copy link
Contributor Author

pbardea commented Sep 23, 2019

bors r=dt

craig bot pushed a commit that referenced this pull request Sep 23, 2019
40996: sql: fix lease interaction with offline tables r=dt a=pbardea

This updates the lease management code to handle offline tables the
same way dropped tables are handled. We are not supposed to be able
to acquire a lease on offline tables (as well as dropped tables).

Fixes #40951 and therefore #40361.

Release justification: Fixes test flakes where a table descriptor lease
is being taken on an offline table.

Release note: None

Co-authored-by: Paul Bardea <pbardea@gmail.com>
@@ -1597,7 +1597,7 @@ func TestImportIntoCSV(t *testing.T) {
<-importBodyFinished

err := sqlDB.DB.QueryRowContext(ctx, `SELECT 1 FROM t`).Scan(&unused)
if !testutils.IsError(err, "table \"t\" is offline: importing") {
if !testutils.IsError(err, "relation \"t\" does not exist") {
Copy link
Member

Choose a reason for hiding this comment

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

not a blocker to a correctness fix, but I did kinda like the more descriptive user-visible error message (and we'd gotten feedback that liked the importing message from others as well).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so the summary here is that the error we were catching was the one thrown when failing to get a lease on the table. this isn't exactly what we want - we want to see the table in the offline state and return it.

the actual PR that changed the error that we're returning here is #40285. That PR changed the logic from returning an error if the table was in a DROP of OFFLINE state to just reporting the object it was looking for as not there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looking in more detail, it looks like that PR (40285) doesn't actually affect this as the behaviour described (returning no object found instead of the error) was always what was happening.

pbardea added a commit to pbardea/cockroach that referenced this pull request Sep 23, 2019
Previously a wait loop was needed in the backup2TB roachtest because the
test was reporting the table as offline when it shouldn't have seen it
as OFFLINE. This was fixed by cockroachdb#40996, and therefore we should no longer
need this wait loop.

Release justification: Only touches tests.

Release note: None
@craig
Copy link
Contributor

craig bot commented Sep 23, 2019

Build succeeded

@craig craig bot merged commit 573e349 into cockroachdb:master Sep 23, 2019
@nvanbenschoten
Copy link
Member

Thanks for tracking this down @pbardea.

@nvanbenschoten
Copy link
Member

Did you mean to close #40361 with this PR?

@pbardea
Copy link
Contributor Author

pbardea commented Sep 24, 2019 via email

craig bot pushed a commit that referenced this pull request Oct 8, 2019
41010: roachtest: remove wait loop in backup2TB roachtest r=pbardea a=pbardea

Previously a wait loop was needed in the backup2TB roachtest because the
test was reporting the table as offline when it shouldn't have seen it
as OFFLINE. This was fixed by #40996, and therefore we should no longer
need this wait loop.

Closes #36841.

Release justification: Only touches tests.

Release note: None

41250: opt: map and push down equality conditions r=rytaft a=rytaft

This commit adds a new normalization rule to enable pushing variable
equality conditions such as `a.x=b.x` through joins.

For example, consider this query:

  `SELECT * FROM a, b, c WHERE a.x=b.x AND a.x=c.x`

Given join ordering `(a join (b join c))`, it should be possible to infer the
filter `b.x=c.x` and push it down from the top level onto the join `(b join c)`.
This commit enables that mapping and pushdown to happen.

In addition, this commit updates the `AssociateJoin` rule to map as many
equality conditions as possible to use the output columns of the new inner-most
join, allowing those conditions to be pushed onto that join.

For example, consider this query:

  `SELECT * FROM a, b, c WHERE a.x=b.x AND b.x=c.x`

If the AssociateJoin rule creates a new join ordering `(b join (a join c))`,
it should be possible to map `a.x=b.x` to `a.x=c.x` and add it onto the new
inner-most join `(a join c)`. This commit enables that mapping to happen.

Fixes #38716
Fixes #36226

Release note (performance improvement): Improved performance for some join
queries due to improved filter inference during planning.
Release justification: This commit will not be merged before the release
branch is cut.

Co-authored-by: Paul Bardea <pbardea@gmail.com>
Co-authored-by: Rebecca Taft <becca@cockroachlabs.com>
@pbardea pbardea deleted the fix-offline-leases branch November 22, 2019 21:03
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.

backup: TableDescriptor's being seen in offline mode when they should be public
4 participants