There is a project running on PostgreSQL with postgres_fdw. Due to legal reason some user data should be stored only in the remote db on the remote server in the closed country. Now the table that is connected to the remote server becomes unavailable when we lose connection to the remote database and storage. The main database must be available even if the remote database crashed. It should not crash the main database. How to connect two different databases from different locations to ensure data integrity (now it implemented on postgres_fdw)?
And the main requirement of our customer, the data should storage at a remote database only.
A materialized view not suitable, because it stores physically data at main server side.
Any ideas?
-
Your question has been reopened, though I find the accepted status of the answer confusing. You can undo the acceptance by clicking the check mark again, if that is appropriate?Paul White– Paul White ♦2019年11月21日 16:49:05 +00:00Commented Nov 21, 2019 at 16:49
1 Answer 1
I would create a materialized view on the foreign tables.
You can refresh the materialized view while the remote database is available and use it in between.
-
If a remote table /data center crashed, it affect all dependent database tablesMax Sherbakov– Max Sherbakov2019年11月18日 13:50:17 +00:00Commented Nov 18, 2019 at 13:50
-
You don't use them, you use the materialized view instead.Laurenz Albe– Laurenz Albe2019年11月18日 13:56:10 +00:00Commented Nov 18, 2019 at 13:56
-
Stop, I've forgotten, the data should storage at remote database only, its requirement of our customer.Max Sherbakov– Max Sherbakov2019年11月19日 13:30:04 +00:00Commented Nov 19, 2019 at 13:30
-
1Well, then it is obviously impossible. If you keep no copy, and the remote data is inaccessible, you cannot have it.Laurenz Albe– Laurenz Albe2019年11月19日 13:38:02 +00:00Commented Nov 19, 2019 at 13:38
-
1@LaurenzAlbe - even if you did have a materialised view, what would happen if the "crash" was only a network outage and the remote db was still receiving connections and changing data - referential integrity would sail out the window! Basically, I think the OP should consider the implications of the CAP theorem! Something like CockroachDB with it's PostgreSQL compatible protocol might be a possibility, but that would assume that the remote site would want to use it also (very new) - you could still read, but not write when remote unavailable!Vérace– Vérace2019年11月20日 19:13:33 +00:00Commented Nov 20, 2019 at 19:13