Phoenix and HBase Backup/Restore: Does Phoenix Auto‑Sync SYSTEM.CATALOG After HBase Restore?
0 reputation · 28 Feb 2023, 12:02 UTC
0 reputation · 28 Feb 2023, 12:02 UTC
After taking a full HBase backup that includes Phoenix tables, we want to restore the HBase tables and have Phoenix automatically recognize the restored tables without manual catalog manipulation.
Phoenix stores table metadata in the SYSTEM.CATALOG region and relies on HBase’s native backup/restore APIs for HFiles. In some releases, the catalog is not refreshed automatically after restoring HBase tables, requiring a manual REFRESH or catalog rebuild. The behavior may vary between Phoenix 4.x and 5.x, and between snapshots and full backups.
We need to confirm that restored tables appear in Phoenix’s SHOW TABLES output and that data integrity matches pre‑backup baselines (e.g., SELECT COUNT(*) and HBase scans). The process should be repeatable across multiple releases.
1. Does Phoenix automatically update SYSTEM.CATALOG entries when HBase tables are restored from a backup or snapshot?
2. If the catalog is not refreshed, what is the minimal manual intervention required to make Phoenix aware of the restored tables?
3. Are there release‑specific flags or configuration settings that enable automatic catalog synchronization during restore?
28775 reputation · 28 Feb 2023, 19:04 UTC
Phoenix does not automatically synchronize its SYSTEM.CATALOG metadata after an HBase backup or snapshot restore. Manual intervention is required to make the Phoenix server aware of the restored tables.
SYSTEM.CATALOG.phoenix-psql) or JDBC.ALTER SYSTEM FLUSH METADATA;
For Phoenix releases prior to 4.7 the flush command is unavailable; instead use the utility:
!metadata rebuild
or restart the Phoenix query server.INFO org.apache.phoenix.util.MetaDataCache - Reloaded SYSTEM.CATALOG with N entriesSELECT COUNT(*) FROM MY_TABLE;
Confirm it returns the expected count without “table not found” errors.To determine whether the ALTER SYSTEM FLUSH METADATA command is available, please confirm the Phoenix version you are running (e.g., 4.6, 4.7, 5.x). If the version is older than 4.7, a server restart or the !metadata rebuild utility is required instead of the flush command.
Use comments to ask for clarification. Post a solution as an answer.
2,440 reputation · 28 Feb 2023, 16:40 UTC
If you restore HBase on a fresh cluster, start the Phoenix Query Server only after the restore is finished. If Phoenix is already running, the metadata cache will be stale until you force a reload.
!schema sync – run in sqlline; rewrites SYSTEM.CATALOG based on the current HBase tables and drops orphan entries.ALTER SYSTEM FLUSH METADATA; – available in Phoenix 4.7+ and 5.x; forces a cache reload without touching the catalog.SELECT COUNT(*) FROM SYSTEM.CATALOG;
Run the query before and after the sync; the counts should match the expected number of tables.
Running !schema sync rewrites the catalog, so back it up if you need a pre‑sync snapshot. The operation is safe but will remove entries for tables that no longer exist in HBase.