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

lease: leases are not retained after IMPORT INTO #57834

Closed
ajwerner opened this issue Dec 11, 2020 · 3 comments · Fixed by #59375
Closed

lease: leases are not retained after IMPORT INTO #57834

ajwerner opened this issue Dec 11, 2020 · 3 comments · Fixed by #59375
Assignees
Labels
A-schema-descriptors Relating to SQL table/db descriptor handling. C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.

Comments

@ajwerner
Copy link
Contributor

Describe the problem

IMPORT INTO takes a table offline. When the lease manager notices that a table is offline, it marks the table as dropped. When the table comes back online the table, the dropped annotation is never removed. This leads to the lease always being dropped upon dereferencing.

To Reproduce

Run IMPORT INTO on a table and then try to interact with it. With vmodule logging you can see that the lease will get released upon dereference.

Expected behavior

Leases would be retained once the table is back online.

Additional context

Restarting the nodes after the IMPORT INTO will resolve the problem as the invalid state is just in memory.

@ajwerner ajwerner added C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. A-schema-descriptors Relating to SQL table/db descriptor handling. labels Dec 11, 2020
@jordanlewis
Copy link
Member

Andrew, what is the user-visible consequence of this issue?

@jordanlewis
Copy link
Member

Is it that all queries need to query descriptor/namespace on these tables, for every query?

@ajwerner
Copy link
Contributor Author

ajwerner commented Jan 8, 2021

Is it that all queries need to query descriptor/namespace on these tables, for every query?

Exactly. Unless the nodes is restarted.

@thoszhang thoszhang assigned thoszhang and postamar and unassigned thoszhang Jan 19, 2021
postamar pushed a commit to postamar/cockroach that referenced this issue Jan 25, 2021
Tables can temporarily be taken offline, either permanently or
temporarily. For example, executing a DROP TABLE statement will take
a table offline permanently, and an IMPORT INTO will take a table
offline only for the duration of the import and will bring it online
again afterward.

Previously, the lease manager would not distinguish between those two
cases and would behave as if the table was gone forever. As a result any
lease acquired after the table came back online would always be dropped
upon dereferencing. Although this behavior is valid, it is inefficient,
hence this patch.

Fixes cockroachdb#57834.

Release note: None
craig bot pushed a commit that referenced this issue Jan 27, 2021
59375: lease: fix lease retention bug for tables taken offline r=postamar a=postamar

Tables can temporarily be taken offline, either permanently or
temporarily. For example, executing a DROP TABLE statement will take
a table offline permanently, and an IMPORT INTO will take a table
offline only for the duration of the import and will bring it online
again afterward.

Previously, the lease manager would not distinguish between those two
cases and would behave as if the table was gone forever. As a result any
lease acquired after the table came back online would always be dropped
upon dereferencing. Although this behavior is valid, it is inefficient,
hence this patch.

Fixes #57834.

Release note: None

Co-authored-by: Marius Posta <[email protected]>
@craig craig bot closed this as completed in 77acd2f Jan 27, 2021
postamar pushed a commit to postamar/cockroach that referenced this issue Feb 25, 2021
Tables can temporarily be taken offline, either permanently or
temporarily. For example, executing a DROP TABLE statement will take
a table offline permanently, and an IMPORT INTO will take a table
offline only for the duration of the import and will bring it online
again afterward.

Previously, the lease manager would not distinguish between those two
cases and would behave as if the table was gone forever. As a result any
lease acquired after the table came back online would always be dropped
upon dereferencing. Although this behavior is valid, it is inefficient,
hence this patch.

Fixes cockroachdb#57834.

Release note: None
postamar pushed a commit to postamar/cockroach that referenced this issue Feb 25, 2021
Tables can temporarily be taken offline, either permanently or
temporarily. For example, executing a DROP TABLE statement will take
a table offline permanently, and an IMPORT INTO will take a table
offline only for the duration of the import and will bring it online
again afterward.

Previously, the lease manager would not distinguish between those two
cases and would behave as if the table was gone forever. As a result any
lease acquired after the table came back online would always be dropped
upon dereferencing. Although this behavior is valid, it is inefficient,
hence this patch.

Fixes cockroachdb#57834.

Release note: None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-schema-descriptors Relating to SQL table/db descriptor handling. C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants