Commit 0abe80fa by Owo Sugiana

Memahami mirror status versi 9.1

1 parent b70ab6ce
0.8.1 21-5-2023
---------------
- Memahami mirror status versi 9.1
0.8 16-5-2023 0.8 16-5-2023
------------- -------------
- Pemahaman konfigurasi mirror yang lebih baik - Pemahaman konfigurasi mirror yang lebih baik
......
...@@ -112,6 +112,18 @@ def pg_port(conf_file): ...@@ -112,6 +112,18 @@ def pg_port(conf_file):
def is_mirror(pg_conf): def is_mirror(pg_conf):
r = Reader(pg_conf) r = Reader(pg_conf)
if 'include_dir' in r:
# Versi 12 - 15
conf_dir = os.path.split(pg_conf)[0]
mirror_conf = os.path.join(conf_dir, r['include_dir'], 'recovery.conf')
if os.path.exists(mirror_conf):
return True
# Versi 9.1 - 11
mirror_conf = os.path.join(r['data_directory'], 'recovery.conf')
if os.path.exists(mirror_conf):
return True
if 'primary_conninfo' in r:
return True
port = r['port'] port = r['port']
# Versi 11 - 15 # Versi 11 - 15
cmd_psql = f'psql -p {port} -c "SHOW primary_conninfo"' cmd_psql = f'psql -p {port} -c "SHOW primary_conninfo"'
...@@ -124,17 +136,6 @@ def is_mirror(pg_conf): ...@@ -124,17 +136,6 @@ def is_mirror(pg_conf):
s = out.decode('utf-8') s = out.decode('utf-8')
if s: if s:
return True return True
if 'include_dir' in r:
# Versi 12 - 15
conf_dir = os.path.split(pg_conf)[0]
mirror_conf = os.path.join(conf_dir, r['include_dir'], 'recovery.conf')
if os.path.exists(mirror_conf):
return True
# Versi 9.1 - 11
mirror_conf = os.path.join(r['data_directory'], 'recovery.conf')
if os.path.exists(mirror_conf):
return True
return 'recovery_target_timeline' in r
def is_db_exists(version, port, db_name): def is_db_exists(version, port, db_name):
......
RE_PREFIX = r'([\d]*)-([\d]*)-([\d]*) ([\d]*):([\d]*):([\d]*).([\d]*) '\ RE_PREFIX = r'([\d]*)-([\d]*)-([\d]*) ([\d]*):([\d]*):([\d]*).([\d]*) '\
r'([A-Z]*) .([\d]*). ' r'([A-Z]*) .([\d]*). '
# 2023-05-21 09:56:50.553 WIB [2429] LOG: streaming replication successfully
# connected to primary
# 2022-01-03 07:04:42.728 WIB [1268975] LOG: started streaming WAL from # 2022-01-03 07:04:42.728 WIB [1268975] LOG: started streaming WAL from
# primary at 3/B6000000 on timeline 1 # primary at 3/B6000000 on timeline 1
# 2023-05-09 07:29:49.335 WIB [3811560] DETAIL: Last completed transaction was # 2023-05-09 07:29:49.335 WIB [3811560] DETAIL: Last completed transaction was
# at log time 2023-05-09 07:28:19.547035+07. # at log time 2023-05-09 07:28:19.547035+07.
RE_OK = RE_PREFIX + '(LOG: started streaming WAL|DETAIL: Last completed)' RE_OK = RE_PREFIX + '(LOG: streaming replication successfully|'\
'LOG: started streaming WAL|DETAIL: Last completed)'
# 2022-01-03 07:04:10.757 WIB [1258171] FATAL: terminating walreceiver due to # 2022-01-03 07:04:10.757 WIB [1258171] FATAL: terminating walreceiver due to
# timeout # timeout
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!