You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gravitino.apache.org by "danhuawang (via GitHub)" <gi...@apache.org> on 2026/06/05 12:04:30 UTC

[PR] [#11122 ][#11112] docs(upgrade): Improve PostgreSQL backup format and add rollback instructions [gravitino]

danhuawang opened a new pull request, #11461:
URL: https://github.com/apache/gravitino/pull/11461

   ### What changes were proposed in this pull request?
   
   This PR improves the `docs/how-to-upgrade.md` documentation with the following changes:
   
   1. Changed the PostgreSQL data backup command to use `-Fc` (custom compressed binary format) instead of `-F c`, producing a `.dump` file instead of `.sql`, and added a note explaining the custom format.
   2. Changed the PostgreSQL schema dump command to use plain-text format (`-f`) instead of custom format (`-F c`), making it easier to diff against official schema files.
   3. Improved the wording in Step 4 (schema comparison) to clarify which differences are acceptable (e.g., object ordering, comments) and which need manual resolution (e.g., table structures, column types, missing tables/indexes).
   4. Added a new "Rollback if Upgrade Fails" section with restore instructions for MySQL, H2, and PostgreSQL backends.
   
   ### Why are the changes needed?
   
   1. The previous PostgreSQL backup command used `-F c` (custom format) but saved to a `.sql` extension, which is misleading. The custom format should use a `.dump` extension and be restored with `pg_restore`.
   2. The schema dump should be in plain-text format so users can directly diff it against the official schema SQL files.
   3. The original documentation lacked rollback guidance, leaving users without a clear recovery path if an upgrade fails.
   
   Fix: #11112
   #11122
   
   ### Does this PR introduce _any_ user-facing change?
   
   No. This is a documentation-only change.
   
   ### How was this patch tested?
   
   Documentation-only change. Verified the commands are correct by reviewing PostgreSQL and MySQL official documentation.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#11122 ][#11112] docs(upgrade): Improve PostgreSQL backup format and add rollback instructions [gravitino]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #11461:
URL: https://github.com/apache/gravitino/pull/11461#issuecomment-4631977165

   <!-- coverage-report -->
   ### Code Coverage Report
   |Overall Project|66.93% **`+0.08%`**|:green_circle:|
   |:-|:-|:-:|
   |Files changed|78.1%|:green_circle:|
   <br>
   
   |Module|Coverage||
   |:-|:-|:-:|
   |aliyun|1.72%|:red_circle:|
   |api|46.8%|:green_circle:|
   |authorization-common|85.96%|:green_circle:|
   |aws|3.66%|:red_circle:|
   |azure|2.47%|:red_circle:|
   |catalog-common|10.04%|:red_circle:|
   |catalog-fileset|80.35%|:green_circle:|
   |catalog-glue|66.67%|:green_circle:|
   |catalog-hive|79.35%|:green_circle:|
   |catalog-jdbc-clickhouse|80.02%|:green_circle:|
   |catalog-jdbc-common|45.31%|:green_circle:|
   |catalog-jdbc-doris|80.28%|:green_circle:|
   |catalog-jdbc-hologres|54.03%|:green_circle:|
   |catalog-jdbc-mysql|79.23%|:green_circle:|
   |catalog-jdbc-oceanbase|78.38%|:green_circle:|
   |catalog-jdbc-postgresql|82.29%|:green_circle:|
   |catalog-jdbc-starrocks|78.51%|:green_circle:|
   |catalog-kafka|77.01%|:green_circle:|
   |catalog-lakehouse-generic|44.89%|:green_circle:|
   |catalog-lakehouse-hudi|79.1%|:green_circle:|
   |catalog-lakehouse-iceberg|85.66%|:green_circle:|
   |catalog-lakehouse-paimon|79.29%|:green_circle:|
   |catalog-model|77.72%|:green_circle:|
   |cli|44.51%|:green_circle:|
   |client-java|77.91%|:green_circle:|
   |common|50.17%|:green_circle:|
   |core|82.48%|:green_circle:|
   |filesystem-hadoop3|76.97%|:green_circle:|
   |flink|0.0%|:red_circle:|
   |flink-common|46.09%|:green_circle:|
   |flink-runtime|0.0%|:red_circle:|
   |gcp|14.12%|:red_circle:|
   |hadoop-common|10.39%|:red_circle:|
   |hive-metastore-common|53.42%|:green_circle:|
   |iceberg-common|56.54%|:green_circle:|
   |iceberg-rest-server|73.5% **`+0.89%`**|:green_circle:|
   |idp-basic|85.99%|:green_circle:|
   |integration-test-common|0.0%|:red_circle:|
   |jobs|66.17%|:green_circle:|
   |lance-common|20.83%|:red_circle:|
   |lance-rest-server|60.27%|:green_circle:|
   |lineage|53.02%|:green_circle:|
   |optimizer|82.87%|:green_circle:|
   |optimizer-api|21.95%|:red_circle:|
   |server|85.73%|:green_circle:|
   |server-common|73.28%|:green_circle:|
   |spark|29.85%|:red_circle:|
   |spark-common|41.01%|:green_circle:|
   |trino-connector|39.97%|:red_circle:|
   
   <details>
   <summary>Files</summary>
   
   |Module|File|Coverage||
   |:-|:-|:-|:-:|
   |iceberg-rest-server|[IcebergRESTUtils.java](https://github.com/danhuawang/gravitino/blob/a30b131daaae505341052c5180b621837241b4fd/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/IcebergRESTUtils.java)|86.44%|:green_circle:|
   ||[CatalogWrapperForREST.java](https://github.com/danhuawang/gravitino/blob/a30b131daaae505341052c5180b621837241b4fd/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/CatalogWrapperForREST.java)|76.91%|:green_circle:|
   ||[IcebergCatalogWrapperManager.java](https://github.com/danhuawang/gravitino/blob/a30b131daaae505341052c5180b621837241b4fd/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/IcebergCatalogWrapperManager.java)|69.81%|:green_circle:|
   
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#11122 ][#11112] docs(upgrade): Improve PostgreSQL backup format and add rollback instructions [gravitino]

Posted by "danhuawang (via GitHub)" <gi...@apache.org>.
danhuawang commented on code in PR #11461:
URL: https://github.com/apache/gravitino/pull/11461#discussion_r3371686099


##########
docs/how-to-upgrade.md:
##########
@@ -206,4 +212,43 @@ Confirm the running image tag matches the target version:
 kubectl get pods -n <namespace> -o jsonpath='{.items[*].spec.containers[*].image}'
 ```
 
+## Rollback if Upgrade Fails

Review Comment:
   Fixed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#11122 ][#11112] docs(upgrade): Improve PostgreSQL backup format and add rollback instructions [gravitino]

Posted by "danhuawang (via GitHub)" <gi...@apache.org>.
danhuawang commented on code in PR #11461:
URL: https://github.com/apache/gravitino/pull/11461#discussion_r3371688555


##########
docs/how-to-upgrade.md:
##########
@@ -206,4 +212,43 @@ Confirm the running image tag matches the target version:
 kubectl get pods -n <namespace> -o jsonpath='{.items[*].spec.containers[*].image}'
 ```
 
+## Rollback if Upgrade Fails
+
+If you encounter errors during the upgrade process, you can
+restore your database from the backup created in Step 2.
+
+### MySQL
+
+Use the backup file to restore your database. The `mysqldump`
+backup contains `DROP TABLE` statements by default (via `--opt`),
+so it will replace the upgraded tables automatically:
+
+```shell
+mysql -u username -h hostname <db_name> < backup.sql
+```
+
+### H2
+
+Replace the current database directory with the copy you made
+during the backup step:
+
+```shell
+rm -rf <db_directory>
+cp -r <db_directory_backup> <db_directory>
+```
+
+### PostgreSQL
+
+Use `pg_restore` with `--clean` to drop existing objects before
+restoring them in one transaction. This is safer than manually
+dropping the schema first:
+
+```shell
+pg_restore -U username -h hostname -d database_name --clean --if-exists --single-transaction data_backup.dump

Review Comment:
   Fixed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#11122 ][#11112] docs(upgrade): Improve PostgreSQL backup format and add rollback instructions [gravitino]

Posted by "danhuawang (via GitHub)" <gi...@apache.org>.
danhuawang commented on code in PR #11461:
URL: https://github.com/apache/gravitino/pull/11461#discussion_r3371689672


##########
docs/how-to-upgrade.md:
##########
@@ -49,8 +49,10 @@ by creating a copy of the directory containing your database.
 For PostgreSQL, you can use the following command to backup your database:
 
 ```shell
-pg_dump -U username -h hostname -d database_name -n schema_name -a -F c -f data_backup.sql
+pg_dump -U username -h hostname -d database_name -n schema_name -Fc -f data_backup.dump
 ```
+The `-Fc` option produces a compressed binary dump in PostgreSQL's
+custom format, which can be restored with `pg_restore`.

Review Comment:
   Fixed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#11122 ][#11112] docs(upgrade): Improve PostgreSQL backup format and add rollback instructions [gravitino]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #11461:
URL: https://github.com/apache/gravitino/pull/11461#discussion_r3370723040


##########
docs/how-to-upgrade.md:
##########
@@ -98,8 +100,12 @@ Gravitino. The files in this directory with names like
 corresponding to each of the released versions of Gravitino. You can
 determine differences between your schema and the official schema
 by comparing the contents of the official dump with the schema dump
-you created in the previous step. Some differences are acceptable and will not interfere
-with the upgrade process, but others need to be resolved manually
+you created in the previous step.
+

Review Comment:
   This PR is marked as fixing #11112, but Step 4 still doesn’t include a concrete command/example for comparing the dumped schema against the official schema file. Adding a simple `diff` example (and a direct reference to `scripts/postgresql/schema-x.y.z-postgresql.sql`) would make the instructions actionable and address the original issue request.



##########
docs/how-to-upgrade.md:
##########
@@ -49,8 +49,10 @@ by creating a copy of the directory containing your database.
 For PostgreSQL, you can use the following command to backup your database:
 
 ```shell
-pg_dump -U username -h hostname -d database_name -n schema_name -a -F c -f data_backup.sql
+pg_dump -U username -h hostname -d database_name -n schema_name -Fc -f data_backup.dump
 ```
+The `-Fc` option produces a compressed binary dump in PostgreSQL's
+custom format, which can be restored with `pg_restore`.

Review Comment:
   The added PostgreSQL backup guidance correctly switches to a custom-format `.dump`, but the IRC PostgreSQL example just below still uses custom format (`-F c`) while writing to a `.sql` file. That’s misleading because the output won’t be plain SQL and should be restored with `pg_restore` (same as the main backup).



##########
docs/how-to-upgrade.md:
##########
@@ -206,4 +212,43 @@ Confirm the running image tag matches the target version:
 kubectl get pods -n <namespace> -o jsonpath='{.items[*].spec.containers[*].image}'
 ```
 
+## Rollback if Upgrade Fails
+
+If you encounter errors during the upgrade process, you can
+restore your database from the backup created in Step 2.
+
+### MySQL
+
+Use the backup file to restore your database. The `mysqldump`
+backup contains `DROP TABLE` statements by default (via `--opt`),
+so it will replace the upgraded tables automatically:
+
+```shell
+mysql -u username -h hostname <db_name> < backup.sql

Review Comment:
   The MySQL rollback command uses `<db_name>` inside the shell command (`mysql ... <db_name> < backup.sql`). In a shell, the `<` characters are input-redirection operators, so copying this literally will fail. Use a placeholder without angle brackets (or pass the DB via `--database`).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#11122 ][#11112] docs(upgrade): Improve PostgreSQL backup format and add rollback instructions [gravitino]

Posted by "danhuawang (via GitHub)" <gi...@apache.org>.
danhuawang commented on code in PR #11461:
URL: https://github.com/apache/gravitino/pull/11461#discussion_r3371574043


##########
docs/how-to-upgrade.md:
##########
@@ -98,8 +100,12 @@ Gravitino. The files in this directory with names like
 corresponding to each of the released versions of Gravitino. You can
 determine differences between your schema and the official schema
 by comparing the contents of the official dump with the schema dump
-you created in the previous step. Some differences are acceptable and will not interfere
-with the upgrade process, but others need to be resolved manually
+you created in the previous step.
+

Review Comment:
   I tried using the diff command, but it generates too much noise, like differences caused purely by line ordering.I suggest avoiding specific tool recommendations here to keep the guidance general.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#11122 ][#11112] docs(upgrade): Improve PostgreSQL backup format and add rollback instructions [gravitino]

Posted by "danhuawang (via GitHub)" <gi...@apache.org>.
danhuawang commented on code in PR #11461:
URL: https://github.com/apache/gravitino/pull/11461#discussion_r3371690712


##########
docs/how-to-upgrade.md:
##########
@@ -206,4 +212,43 @@ Confirm the running image tag matches the target version:
 kubectl get pods -n <namespace> -o jsonpath='{.items[*].spec.containers[*].image}'
 ```
 
+## Rollback if Upgrade Fails
+
+If you encounter errors during the upgrade process, you can
+restore your database from the backup created in Step 2.
+
+### MySQL
+
+Use the backup file to restore your database. The `mysqldump`
+backup contains `DROP TABLE` statements by default (via `--opt`),
+so it will replace the upgraded tables automatically:
+
+```shell
+mysql -u username -h hostname <db_name> < backup.sql

Review Comment:
   Fixed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#11122 ][#11112] docs(upgrade): Improve PostgreSQL backup format and add rollback instructions [gravitino]

Posted by "danhuawang (via GitHub)" <gi...@apache.org>.
danhuawang commented on code in PR #11461:
URL: https://github.com/apache/gravitino/pull/11461#discussion_r3371684316


##########
docs/how-to-upgrade.md:
##########
@@ -49,8 +49,10 @@ by creating a copy of the directory containing your database.
 For PostgreSQL, you can use the following command to backup your database:
 
 ```shell
-pg_dump -U username -h hostname -d database_name -n schema_name -a -F c -f data_backup.sql
+pg_dump -U username -h hostname -d database_name -n schema_name -Fc -f data_backup.dump

Review Comment:
   Fixed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#11122 ][#11112] docs(upgrade): Improve PostgreSQL backup format and add rollback instructions [gravitino]

Posted by "yuqi1129 (via GitHub)" <gi...@apache.org>.
yuqi1129 merged PR #11461:
URL: https://github.com/apache/gravitino/pull/11461


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#11122 ][#11112] docs(upgrade): Improve PostgreSQL backup format and add rollback instructions [gravitino]

Posted by "yuqi1129 (via GitHub)" <gi...@apache.org>.
yuqi1129 commented on code in PR #11461:
URL: https://github.com/apache/gravitino/pull/11461#discussion_r3362651934


##########
docs/how-to-upgrade.md:
##########
@@ -49,8 +49,10 @@ by creating a copy of the directory containing your database.
 For PostgreSQL, you can use the following command to backup your database:
 
 ```shell
-pg_dump -U username -h hostname -d database_name -n schema_name -a -F c -f data_backup.sql
+pg_dump -U username -h hostname -d database_name -n schema_name -Fc -f data_backup.dump

Review Comment:
   The `-a` (data-only) flag was silently dropped here. The original command backed up data only; this new command backs up both schema and data. That's actually the right behaviour for rollback purposes, but it should be explicitly documented — the added note only mentions the format change. Please add a sentence explaining this semantic difference, e.g.: "Unlike the previous command, this backup includes both schema and data, which is necessary for a full rollback."



##########
docs/how-to-upgrade.md:
##########
@@ -206,4 +212,43 @@ Confirm the running image tag matches the target version:
 kubectl get pods -n <namespace> -o jsonpath='{.items[*].spec.containers[*].image}'
 ```
 
+## Rollback if Upgrade Fails

Review Comment:
   The rollback section is missing a critical prerequisite: the Gravitino server must be stopped before any restore is performed, otherwise concurrent writes can corrupt the database. Please add a note at the top of this section, e.g.:\n\n> **Important:** Stop the Gravitino server before restoring the database to avoid data corruption from concurrent writes.



##########
docs/how-to-upgrade.md:
##########
@@ -206,4 +212,43 @@ Confirm the running image tag matches the target version:
 kubectl get pods -n <namespace> -o jsonpath='{.items[*].spec.containers[*].image}'
 ```
 
+## Rollback if Upgrade Fails
+
+If you encounter errors during the upgrade process, you can
+restore your database from the backup created in Step 2.
+
+### MySQL
+
+Use the backup file to restore your database. The `mysqldump`
+backup contains `DROP TABLE` statements by default (via `--opt`),
+so it will replace the upgraded tables automatically:
+
+```shell
+mysql -u username -h hostname <db_name> < backup.sql
+```
+
+### H2
+
+Replace the current database directory with the copy you made
+during the backup step:
+
+```shell
+rm -rf <db_directory>
+cp -r <db_directory_backup> <db_directory>
+```
+
+### PostgreSQL
+
+Use `pg_restore` with `--clean` to drop existing objects before
+restoring them in one transaction. This is safer than manually
+dropping the schema first:
+
+```shell
+pg_restore -U username -h hostname -d database_name --clean --if-exists --single-transaction data_backup.dump

Review Comment:
   Two issues with this restore command:\n\n1. **Missing schema filter**: the backup was taken with `-n schema_name`, so the restore should include `--schema=schema_name` (or `-n schema_name`) for symmetry. Without it, the behaviour depends on what is in the dump and may confuse users.\n\n2. **`--clean` limitation**: `pg_restore --clean` only drops objects that are present in the dump file. If the upgrade scripts added new tables or sequences not present in the backup, those objects will remain after the restore and may leave the database in an inconsistent state. Worth adding a note such as: "Note: objects added by the upgrade scripts that are not in the backup will not be removed automatically; verify the schema matches the expected state after restoring."\n\nSuggested command:\n```shell\npg_restore -U username -h hostname -d database_name -n schema_name --clean --if-exists --single-transaction data_backup.dump\n```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org