-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Views are broken after dumping and loading database with SCRIPT
/RUNSCRIPT
#3942
Comments
johnswanson
added a commit
to metabase/metabase
that referenced
this issue
Dec 8, 2023
There's a fun bug in H2: h2database/h2database#3942 To reproduce: - create a table, then - create a view based on the table, then - modify the original table, then - generate a snapshot The generated snapshot has the `CREATE VIEW` *before* the `CREATE TABLE`. This results in a view that can't be queried successfully until it is recompiled. Our workaround is to recompile ALL views immediately after we restore the app DB from a snapshot.
johnswanson
added a commit
to metabase/metabase
that referenced
this issue
Dec 8, 2023
There's a fun bug in H2: h2database/h2database#3942 To reproduce: - create a table, then - create a view based on the table, then - modify the original table, then - generate a snapshot The generated snapshot has the `CREATE VIEW` *before* the `CREATE TABLE`. This results in a view that can't be queried successfully until it is recompiled. Our workaround is to recompile ALL views immediately after we restore the app DB from a snapshot.
johnswanson
added a commit
to metabase/metabase
that referenced
this issue
Dec 8, 2023
There's a fun bug in H2: h2database/h2database#3942 To reproduce: - create a table, then - create a view based on the table, then - modify the original table, then - generate a snapshot The generated snapshot has the `CREATE VIEW` *before* the `CREATE TABLE`. This results in a view that can't be queried successfully until it is recompiled. Our workaround is to recompile ALL views immediately after we restore the app DB from a snapshot.
github-actions bot
pushed a commit
to metabase/metabase
that referenced
this issue
Dec 8, 2023
There's a fun bug in H2: h2database/h2database#3942 To reproduce: - create a table, then - create a view based on the table, then - modify the original table, then - generate a snapshot The generated snapshot has the `CREATE VIEW` *before* the `CREATE TABLE`. This results in a view that can't be queried successfully until it is recompiled. Our workaround is to recompile ALL views immediately after we restore the app DB from a snapshot.
metabase-bot bot
added a commit
to metabase/metabase
that referenced
this issue
Dec 8, 2023
There's a fun bug in H2: h2database/h2database#3942 To reproduce: - create a table, then - create a view based on the table, then - modify the original table, then - generate a snapshot The generated snapshot has the `CREATE VIEW` *before* the `CREATE TABLE`. This results in a view that can't be queried successfully until it is recompiled. Our workaround is to recompile ALL views immediately after we restore the app DB from a snapshot. Co-authored-by: John Swanson <john.swanson@metabase.com>
qnkhuat
pushed a commit
to metabase/metabase
that referenced
this issue
Dec 12, 2023
There's a fun bug in H2: h2database/h2database#3942 To reproduce: - create a table, then - create a view based on the table, then - modify the original table, then - generate a snapshot The generated snapshot has the `CREATE VIEW` *before* the `CREATE TABLE`. This results in a view that can't be queried successfully until it is recompiled. Our workaround is to recompile ALL views immediately after we restore the app DB from a snapshot.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, I think I've found a bug in the
SCRIPT
command which breaks views under certain conditions.On an empty H2 database, issue these commands:
Then run
SCRIPT TO 'bug-repro-dump.sql';
Here is the contents of the script file:
On a second empty H2 database run
RUNSCRIPT 'bug-repro-dump.sql';
Now if you try to read the view on the second database, you get an error:
Unless you recompile the view first:
Essentially, updating the table after creating the view causes the
CREATE TABLE
command to be moved below theCREATE FORCE VIEW
command in the script file, breaking the view when the script is run but not reporting any errors until the view is queried.I've tested the equivalent behavior on Postgres using
pg_dump
and it doesn't have the same issue, so I'm assuming this is a bug in H2 and not intentional behavior.The text was updated successfully, but these errors were encountered: