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

Give a notice when dropping an in-use index #21706

Merged
merged 1 commit into from
Sep 20, 2023

Conversation

ggevay
Copy link
Contributor

@ggevay ggevay commented Sep 11, 2023

This is the first step of addressing https://github.com/MaterializeInc/database-issues/issues/6111: We give a notice when the user drops an index that is in use.

I'm planning to open a follow-up PR that will add some documentation about this situation, and will link to that in the notice message.

Note that the computation of reverse_compute_dependencies is not very efficient, because it goes through all collections. But we decided with Jan that this is ok, and it's not worth it to make it more complicated for efficiency, because this should still take less than 1 ms, and dropping an index is not performance critical.

Motivation

Tips for reviewer

Checklist

@ggevay ggevay force-pushed the drop-used-index-notice branch 2 times, most recently from cd8f6e1 to b257446 Compare September 19, 2023 11:38
@ggevay ggevay added A-optimization Area: query optimization and transformation A-compute Area: compute labels Sep 19, 2023
@ggevay ggevay marked this pull request as ready for review September 19, 2023 11:59
@ggevay ggevay requested a review from a team September 19, 2023 11:59
@ggevay ggevay requested a review from a team as a code owner September 19, 2023 11:59
Copy link
Contributor

@umanwizard umanwizard left a comment

Choose a reason for hiding this comment

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

Thanks!

index_name,
dependant_objects,
}) => {
write!(f, "The dropped index {index_name} is being used by the following objects: {}. The index will be dropped from the catalog, but it will continue to be maintained and take up resources!", separated(", ", dependant_objects))
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also say something about the fact that the index will cease to exist on next restart?

Copy link
Contributor

Choose a reason for hiding this comment

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

The hint() for this notice variant mentions this.

We discussed this and this seems the fact that we re-plan during the maintenance window is incidental, so I'm not sure if we should mention this here.

Copy link
Contributor Author

@ggevay ggevay Sep 20, 2023

Choose a reason for hiding this comment

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

The hint says
"To free up the resources used by the index, recreate all the above-mentioned objects."

We were thinking with Alex to not emphasize the maintenance window restart too much, because it's just an incidental thing, e.g., it might not occur if there is no release on a certain week. Also, we don't want users waiting for the maintenance window with the replanning, because then if the index disappearing creates a performance problem then we'd get confused whether it was the version upgrade or just an index being dropped.

But I'm planning to open a follow-up PR with adding docs for these notices, and there I will probably mention this anyway.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree about not mentioning the maintenance window here. It would be weird to have the database code make assumptions about how we operate Materialize.

We could mention Materialize restarts in a generic way (which is what Brennan suggested I think) but then there is nothing actionable the user can do with that information, so I don't see how it would be useful.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's important for the user to be aware that at some point in the future, outside of their control, the objects using this index will become less efficient as they will no longer have access to the index. We don't need to specifically mention maintenance windows, I guess.

Copy link
Contributor

@aalexandrov aalexandrov Sep 20, 2023

Choose a reason for hiding this comment

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

Well, I can imagine this happening, unfortunately.

This seems like an anti-pattern. Until we implement plan pinning as a feature that is enabled by default for every installed materialized view and index dataflow, users should not rely on their plans being stable across restarts, especially if they change the environment in the meantime.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree that users should not be relying on this, but unfortunately I think some will rely on it unless we explicitly teach them not to.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, so what should be the wording? This is the current wording:

"The dropped index {index_name} is being used by the following objects: {}. The index will be dropped from the catalog, but it will continue to be maintained and take up resources!"

we could instead have

"The dropped index {index_name} is being used by the following objects (until they are dropped or Materialize is restarted): {}. The index is now dropped from the catalog, but it will continue to be maintained and take up resources!"

What do you all think?

Copy link
Contributor

@aalexandrov aalexandrov Sep 20, 2023

Choose a reason for hiding this comment

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

I suggest

until they are dropped, altered or Materialize is restarted

in order to also cover #20725.

Copy link
Contributor Author

@ggevay ggevay Sep 21, 2023

Choose a reason for hiding this comment

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

I've opened a PR with the following:

"The dropped index {index_name} is being used by the following objects: {}. The index is now dropped from the catalog, but it will continue to be maintained and take up resources until all dependent objects are dropped, altered, or Materialize is restarted!"

Copy link
Contributor

@aalexandrov aalexandrov left a comment

Choose a reason for hiding this comment

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

Some minor nits, otherwise looks good.

ReadyForQuery {"status":"I"}
CommandComplete {"tag":"CREATE MATERIALIZED VIEW"}
ReadyForQuery {"status":"I"}
NoticeResponse {"fields":[{"typ":"S","value":"NOTICE"},{"typ":"C","value":"01000"},{"typ":"M","value":"The dropped index materialize.public.t_idx_a is being used by the following objects: materialize.public.mv2. The index will be dropped from the catalog, but it will continue to be maintained and take up resources!"}]}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure what the difference in the setup between the two notices is. Can we have one which tests the "index being used in the dataflow maintaining another index" path?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

src/compute-client/src/controller/instance.rs Outdated Show resolved Hide resolved
src/compute-client/src/controller/instance.rs Show resolved Hide resolved
src/compute-client/src/controller/instance.rs Show resolved Hide resolved
src/adapter/src/coord/sequencer/inner.rs Outdated Show resolved Hide resolved
index_name,
dependant_objects,
}) => {
write!(f, "The dropped index {index_name} is being used by the following objects: {}. The index will be dropped from the catalog, but it will continue to be maintained and take up resources!", separated(", ", dependant_objects))
Copy link
Contributor

Choose a reason for hiding this comment

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

The hint() for this notice variant mentions this.

We discussed this and this seems the fact that we re-plan during the maintenance window is incidental, so I'm not sure if we should mention this here.

Copy link
Contributor

@teskje teskje left a comment

Choose a reason for hiding this comment

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

LGTM, just a couple nits!

src/adapter/src/coord/sequencer/inner.rs Outdated Show resolved Hide resolved
index_name,
dependant_objects,
}) => {
write!(f, "The dropped index {index_name} is being used by the following objects: {}. The index will be dropped from the catalog, but it will continue to be maintained and take up resources!", separated(", ", dependant_objects))
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree about not mentioning the maintenance window here. It would be weird to have the database code make assumptions about how we operate Materialize.

We could mention Materialize restarts in a generic way (which is what Brennan suggested I think) but then there is nothing actionable the user can do with that information, so I don't see how it would be useful.

src/compute-client/src/controller.rs Show resolved Hide resolved
src/compute-client/src/controller/instance.rs Outdated Show resolved Hide resolved
@ggevay ggevay merged commit f176f13 into MaterializeInc:main Sep 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-compute Area: compute A-optimization Area: query optimization and transformation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants