Skip to content

Commit ccdf25e

Browse files
committed
Adapt to PG 12 where recovery.conf is obsolete.
1 parent 568603c commit ccdf25e

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

Diff for: testgres/node.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,15 @@ def _create_recovery_conf(self, username, slot=None):
336336

337337
line = (
338338
"primary_conninfo='{}'\n"
339-
"standby_mode=on\n"
340339
).format(options_string(**conninfo)) # yapf: disable
340+
# Since 12 recovery.conf had disappeared
341+
if self.version >= '12':
342+
signal_name = os.path.join(self.data_dir, "standby.signal")
343+
# cross-python touch(). It is vulnerable to races, but who cares?
344+
with open(signal_name, 'a'):
345+
os.utime(signal_name, None)
346+
else:
347+
line += "standby_mode=on\n"
341348

342349
if slot:
343350
# Connect to master for some additional actions
@@ -363,7 +370,10 @@ def _create_recovery_conf(self, username, slot=None):
363370

364371
line += "primary_slot_name={}\n".format(slot)
365372

366-
self.append_conf(filename=RECOVERY_CONF_FILE, line=line)
373+
if self.version >= '12':
374+
self.append_conf(line=line)
375+
else:
376+
self.append_conf(filename=RECOVERY_CONF_FILE, line=line)
367377

368378
def _maybe_start_logger(self):
369379
if testgres_config.use_python_logging:

0 commit comments

Comments
 (0)