Skip to content

sql: change materialized view not to be created with fixed timestamp.#80651

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
Xiang-Gu:materialized_view_created_with_incorrect_fixed_timestamp
May 3, 2022
Merged

sql: change materialized view not to be created with fixed timestamp.#80651
craig[bot] merged 1 commit intocockroachdb:masterfrom
Xiang-Gu:materialized_view_created_with_incorrect_fixed_timestamp

Conversation

@Xiang-Gu
Copy link
Copy Markdown
Contributor

@Xiang-Gu Xiang-Gu commented Apr 27, 2022

Previously, a materialized view was created with fixed time timestamp (
namely, its CreateAsOfTime is initialized to transaction's read time).

If the transaction that created this materialized
view is pushed forward then CreateAsOfTime will be before other
descriptors created in the same transaction, causing the backfill job
for create materialized view to fail because the other, needed
descriptors are not visible at that early CreatedAsOfTime.

We address this by removing the line that sets CreateAsOfTime field
of the materalized view, and it instead will reply on the MVCC protocol
to populate this field based on the MVCC timestamp of the row containing
the needed descriptors when backfilling this materialized view.

fixes: #79015

Release note (bug fix): This PR fixes a bug where if a transaction's
commit time is pushed forward from its initial provisional time, a
enclosing CREATE MATERIALIZED VIEW AS ... might fail to find other
descriptors created in the same transaction during the view's backfill
stage. The detailed description of this bug is summarized in issue #79015.

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@Xiang-Gu Xiang-Gu marked this pull request as ready for review April 28, 2022 17:12
@Xiang-Gu Xiang-Gu requested a review from a team April 28, 2022 17:12
Copy link
Copy Markdown
Contributor

@ajwerner ajwerner left a comment

Choose a reason for hiding this comment

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

:lgtm: once you add a release note (make sure to add it to the PR description too)

Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @Xiang-Gu)


-- commits line 18 at r1:
This deserves a release note and then backports

Previously, a materialized view was created with fixed time timestamp (
namely, its `CreateAsOfTime` is initialized to transaction's read time).

If the transaction that created this materialized
view is pushed forward then `CreateAsOfTime` will be before other
descriptors created in the same transaction, causing the backfill job
for create materialized view to fail because the other, needed
descriptors are not visible at that early `CreatedAsOfTime`.

We address this by removing the line that sets `CreateAsOfTime` field
of the materalized view, and it instead will reply on the MVCC protocol
to populate this field based on the MVCC timestamp of the row containing
the needed descriptors when backfilling this materialized view.

Release note (bug fix): This PR fixes a bug where if a transaction's
commit time is pushed forward from its initial provisional time, a
enclosing `CREATE MATERIALIZED VIEW AS ...` might fail to find other
descriptors created in the same transaction during the view's backfill
stage. The detailed descriptor of this bug is summarized in issue cockroachdb#79015
@Xiang-Gu Xiang-Gu force-pushed the materialized_view_created_with_incorrect_fixed_timestamp branch from 034d8c0 to 044dea4 Compare April 29, 2022 20:10
@Xiang-Gu
Copy link
Copy Markdown
Contributor Author

Xiang-Gu commented May 2, 2022

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented May 2, 2022

Build failed:

Copy link
Copy Markdown
Contributor

@ajwerner ajwerner left a comment

Choose a reason for hiding this comment

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

Unrelated flake

bors r+

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @Xiang-Gu)

@craig
Copy link
Copy Markdown
Contributor

craig bot commented May 3, 2022

Build succeeded:

@blathers-crl
Copy link
Copy Markdown

blathers-crl bot commented May 3, 2022

Encountered an error creating backports. Some common things that can go wrong:

  1. The backport branch might have already existed.
  2. There was a merge conflict.
  3. The backport branch contained merge commits.

You might need to create your backport manually using the backport tool.


error creating merge commit from 044dea4 to blathers/backport-release-21.2-80651: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict []

you may need to manually resolve merge conflicts with the backport tool.

Backport to branch 21.2.x failed. See errors above.


🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan.

@ajwerner
Copy link
Copy Markdown
Contributor

ajwerner commented May 3, 2022

@Xiang-Gu please backport this manually to 21.2

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.

sql: materialized view created with incorrect fixed timestamp

3 participants