adapter: remove apply_item_update optimization
#34241
Open
+23
−25
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When applying an item
StateUpdate, we had an optimization that would skip parsing thecreate_sqlif it hadn't change, and reuse the oldCatalogEntryinstead. This produces the wrong outcome if theextra_versionschange without the SQL changing: Any version updates are not reflected in the newCatalogEntry.To fix this, this PR removes the optimization, under the assumption that DDL is sufficiently rare that we can live without it. If that turns out not the be the case, we can keep the optimization and refine the conditions under which SQL parsing is performed, though that seems brittle.
Motivation
This comes up in the ALTER MV work: A change adding new collection version without changing the
create_sqldoesn't get applied properly, the new version is ignored.Part of https://github.com/MaterializeInc/database-issues/issues/9903
Tips for reviewer
I'm optimistically assuming that this was a premature optimization, but I don't know for sure. It was introduced in #27667 with no motivation given aside from "this is potentially wasteful". I couldn't find any further discussion anywhere else.
Istm that being inefficient when applying DDL changes should be fine, given that DDL should be a relatively rare occurrence. So doing more work here for the sake of robustness seems fine. But I'm missing a bunch of context and maybe
apply_item_updateis invoked more often than I assume.Checklist
$T ⇔ Proto$Tmapping (possibly in a backwards-incompatible way), then it is tagged with aT-protolabel.