2424 DATA_DIR , \
2525 LOGS_DIR , \
2626 PG_CONF_FILE , \
27+ PG_AUTO_CONF_FILE , \
2728 HBA_CONF_FILE , \
2829 RECOVERY_CONF_FILE , \
2930 PG_LOG_FILE , \
@@ -213,22 +214,18 @@ def _maybe_stop_logger(self):
213214 if self ._logger :
214215 self ._logger .stop ()
215216
216- def _format_verbose_error (self , message = None ):
217- # list of important files + N of last lines
217+ def _collect_special_files (self ):
218+ result = []
219+
220+ # list of important files + last N lines
218221 files = [
219222 (os .path .join (self .data_dir , PG_CONF_FILE ), 0 ),
220- (os .path .join (self .data_dir , HBA_CONF_FILE ), 0 ),
223+ (os .path .join (self .data_dir , PG_AUTO_CONF_FILE ), 0 ),
221224 (os .path .join (self .data_dir , RECOVERY_CONF_FILE ), 0 ),
225+ (os .path .join (self .data_dir , HBA_CONF_FILE ), 0 ),
222226 (self .pg_log_name , TestgresConfig .error_log_lines )
223227 ]
224228
225- error_text = ""
226-
227- # append message if asked to
228- if message :
229- error_text += message
230- error_text += '\n ' * 2
231-
232229 for f , num_lines in files :
233230 # skip missing files
234231 if not os .path .exists (f ):
@@ -242,10 +239,10 @@ def _format_verbose_error(self, message=None):
242239 # read whole file
243240 lines = _f .read ().decode ('utf-8' )
244241
245- # append contents
246- error_text += u"{}: \n ---- \n {} \n " . format ( f , lines )
242+ # fill list
243+ result . append (( f , lines ) )
247244
248- return error_text
245+ return result
249246
250247 def init (self ,
251248 fsync = False ,
@@ -427,7 +424,8 @@ def get_pid(self):
427424 """
428425
429426 if self .status ():
430- with io .open (os .path .join (self .data_dir , 'postmaster.pid' )) as f :
427+ pid_file = os .path .join (self .data_dir , 'postmaster.pid' )
428+ with io .open (pid_file ) as f :
431429 return int (f .readline ())
432430
433431 # for clarity
@@ -476,8 +474,9 @@ def start(self, params=[]):
476474 try :
477475 execute_utility (_params , self .utils_log_name )
478476 except ExecUtilException as e :
479- msg = self ._format_verbose_error ('Cannot start node' )
480- raise_from (StartNodeException (msg ), e )
477+ msg = 'Cannot start node'
478+ files = self ._collect_special_files ()
479+ raise_from (StartNodeException (msg , files ), e )
481480
482481 self ._maybe_start_logger ()
483482
@@ -531,8 +530,9 @@ def restart(self, params=[]):
531530 try :
532531 execute_utility (_params , self .utils_log_name )
533532 except ExecUtilException as e :
534- msg = self ._format_verbose_error ('Cannot restart node' )
535- raise_from (StartNodeException (msg ), e )
533+ msg = 'Cannot restart node'
534+ files = self ._collect_special_files ()
535+ raise_from (StartNodeException (msg , files ), e )
536536
537537 self ._maybe_start_logger ()
538538
@@ -693,7 +693,7 @@ def safe_psql(self,
693693 username = username ,
694694 input = input )
695695 if ret :
696- raise QueryException ((err or b'' ).decode ('utf-8' ))
696+ raise QueryException ((err or b'' ).decode ('utf-8' ), query )
697697
698698 return out
699699
@@ -791,13 +791,13 @@ def poll_query_until(self,
791791 return # done
792792
793793 if res is None :
794- raise QueryException ('Query returned None' )
794+ raise QueryException ('Query returned None' , query )
795795
796796 if len (res ) == 0 :
797- raise QueryException ('Query returned 0 rows' )
797+ raise QueryException ('Query returned 0 rows' , query )
798798
799799 if len (res [0 ]) == 0 :
800- raise QueryException ('Query returned 0 columns' )
800+ raise QueryException ('Query returned 0 columns' , query )
801801
802802 if res [0 ][0 ] == expected :
803803 return # done
@@ -910,7 +910,7 @@ def catchup(self, dbname=None, username=None):
910910 username = username ,
911911 max_attempts = 0 ) # infinite
912912 except Exception as e :
913- raise_from (CatchUpException (' Failed to catch up' ), e )
913+ raise_from (CatchUpException (" Failed to catch up" , poll_lsn ), e )
914914
915915 def pgbench (self ,
916916 dbname = None ,
0 commit comments