Phoenix and HBase Backup/Restore: Does Phoenix Auto‑Sync SYSTEM.CATALOG After HBase Restore?
26.5K reputation · 28 Feb 2023, 12:02 UTC
Goal
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.
Constraints & Uncertainty
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.
Verification Needs
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.
Unresolved Questions
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?
1 answer
1 question comment
Use comments to ask for clarification. Post a solution as an answer.
2,180 reputation · 28 Feb 2023, 16:40 UTC
When to Sync
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.
Preferred Sync Commands
!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.
Quick Verification
SELECT COUNT(*) FROM SYSTEM.CATALOG;
Run the query before and after the sync; the counts should match the expected number of tables.
Important Note
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.