Reporting DB Rebuild¶
1. Drop subscription and publication¶
- 1.1 Drop REP DB subscription
Login REP DB server, and switch to user:
postgres
psql -p 6434
\c REP131
select * from pg_catalog.pg_subscription; # check subscriptions
drop subscription sub_pp131 cascade;
If deletion is not possible, you can first execute the below SQL:
```sql alter subscription sub_cim131 DISABLE; alter subscription sub_cim131 SET (slot_name = NONE);
- 1.2 Drop PRD DB publication
Login PRD DB server, and switch to user:
postgres
psql -p 6432
\c MESP131
select * from pg_catalog.pg_publication; # check publications
drop publication pub_pp131 cascade;
2. Re-create publication and subscription¶
- 2.1 Re-create publication (@PRD DB)
create publication pub_pp131
pp131.ppfshiftid,
pp131.uppuhinfo,
pp131.att_skill,
pp131.att_station,
pp131.att_station_audit
with (publish = 'insert, update, delete, truncate', publish_via_partition_root = false);
-
2.2 Re-create subscription (@Rep DB)
-
2.2.1 truncate table
select schema all tables, and general
truncateSQLselect 'truncate table '|| string_agg(schemaname || '.' || relname,', ')||';' from pg_stat_user_tables where schemaname='pp131';copy and execute general
truncateSQL to fast clear table data -
2.2.2 create subscription
```sql CREATE SUBSCRIPTION sub_pp131 CONNECTION 'host={PRD_DB_IP} port=6432 user=postgres dbname=MESP131 password=xxxx' PUBLICATION pub_pp131 WITH (connect = true, enabled = true, create_slot = true, slot_name = sub_pp131, synchronous_commit = 'off');
3. Reporting sync check¶
- 3.1 Subscription endpoint (Reporting) check
- 3.2 Publication endpoint (PRD) check
make sure the
activestatus is alwaystrue
make sure the
activestatus is not set tofalse