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: change when txn is checked refresh materialized views #87271

Merged
merged 1 commit into from
Sep 6, 2022

Conversation

e-mbrown
Copy link
Contributor

@e-mbrown e-mbrown commented Sep 1, 2022

Due to the transaction being checked during planning
and not during execution, refresh materialized views
would fail from the client. Now the transaction is checked
during execution .

Release justification: Bug fix for refresh materialized views

Release note: None

@e-mbrown e-mbrown requested a review from a team September 1, 2022 14:58
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@@ -80,6 +77,10 @@ func (n *refreshMaterializedViewNode) startExec(params runParams) error {
// results of the view query into the new set of indexes, and then change the
// set of indexes over to the new set of indexes atomically.

if !params.p.extendedEvalCtx.TxnIsSingleStmt {
return pgerror.Newf(pgcode.InvalidTransactionState, "cannot refresh view in a multi-statement transaction")
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you add a test in materialized_view_test.go

right below

you can add

	// Verify that refreshing with a prepared statement works.
	preparedStmt, err := sqlDB.Prepare(`REFRESH MATERIALIZED VIEW t.v;`)
	if err != nil {
		t.Fatal(err)
	}
	if _, err := preparedStmt.Exec(); err != nil {
		t.Fatal(err)
	}

Copy link
Contributor Author

@e-mbrown e-mbrown left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @rafiss)


pkg/sql/refresh_materialized_view.go line 82 at r1 (raw file):

Previously, rafiss (Rafi Shamim) wrote…

can you add a test in materialized_view_test.go

right below

you can add

	// Verify that refreshing with a prepared statement works.
	preparedStmt, err := sqlDB.Prepare(`REFRESH MATERIALIZED VIEW t.v;`)
	if err != nil {
		t.Fatal(err)
	}
	if _, err := preparedStmt.Exec(); err != nil {
		t.Fatal(err)
	}

Done.

Copy link
Collaborator

@rafiss rafiss left a comment

Choose a reason for hiding this comment

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

lgtm!

@rafiss
Copy link
Collaborator

rafiss commented Sep 1, 2022

let's make sure this gets backported

materialized views

Due to the transaction being checked during planning
and not during execution, refresh materialized views
would fail from the client. Now the transaction is checked
during execution .

Release justification: Bug fix for refresh materialized views

Release note: None
@e-mbrown
Copy link
Contributor Author

e-mbrown commented Sep 6, 2022

bors r=rafiss

@craig
Copy link
Contributor

craig bot commented Sep 6, 2022

Build failed (retrying...):

@cockroachdb cockroachdb deleted a comment from craig bot Sep 6, 2022
@craig
Copy link
Contributor

craig bot commented Sep 6, 2022

Build succeeded:

@craig craig bot merged commit 825e89e into cockroachdb:master Sep 6, 2022
@blathers-crl
Copy link

blathers-crl bot commented Sep 6, 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 fcf22cd to blathers/backport-release-22.1-87271: 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 22.1.x failed. See errors above.


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

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.

3 participants