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

create_immv could create an inconsistent IMMV with concurrent insert into a base table #104

Open
yugo-n opened this issue Oct 15, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@yugo-n
Copy link
Collaborator

yugo-n commented Oct 15, 2024

If a base table is modified before calling create_immv in a concurrent transaction, create_immv will create an IMMV inconsistent with the latest contents of the table.

  1. Modify a table in a transaction A.
postgres=# begin ;
BEGIN
postgres=*# insert into yyy values (10);
INSERT 0 1
  1. Create an IMMV in a transaction B.
postgres=# begin ;
BEGIN
postgres=*# select create_immv('mvyyy','select * from yyy'); -- blocked
  1. Commit the transaction A.
postgres=*# commit;
COMMIT
postgres=# select * from yyy;
 i  
----
  1
  2
 10
(3 rows)
  1. Commit the transaction B, the IMMV doesn't contain the inserted row.
(cont.)
NOTICE:  could not create an index on immv "mvyyy" automatically
DETAIL:  This target list does not have all the primary key columns, or this view does not contain GROUP BY or DISTINCT clause.
HINT:  Create an index on the immv for efficient incremental maintenance.
 create_immv 
-------------
           2
(1 row)

postgres=*# end;
COMMIT
postgres=# select * from mvyyy;
 i 
---
 1
 2
(2 rows)
@yugo-n yugo-n added the bug Something isn't working label Oct 15, 2024
@yugo-n
Copy link
Collaborator Author

yugo-n commented Oct 15, 2024

When create_immv was called before the table modification, the resultant was correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant