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 , \
@@ -215,22 +216,18 @@ def _maybe_stop_logger(self):
215216 if self ._logger :
216217 self ._logger .stop ()
217218
218- def _format_verbose_error (self , message = None ):
219- # list of important files + N of last lines
219+ def _collect_special_files (self ):
220+ result = {}
221+
222+ # list of important files + last N lines
220223 files = [
221224 (os .path .join (self .data_dir , PG_CONF_FILE ), 0 ),
222- (os .path .join (self .data_dir , HBA_CONF_FILE ), 0 ),
225+ (os .path .join (self .data_dir , PG_AUTO_CONF_FILE ), 0 ),
223226 (os .path .join (self .data_dir , RECOVERY_CONF_FILE ), 0 ),
227+ (os .path .join (self .data_dir , HBA_CONF_FILE ), 0 ),
224228 (self .pg_log_name , TestgresConfig .error_log_lines )
225229 ]
226230
227- error_text = ""
228-
229- # append message if asked to
230- if message :
231- error_text += message
232- error_text += '\n ' * 2
233-
234231 for f , num_lines in files :
235232 # skip missing files
236233 if not os .path .exists (f ):
@@ -244,10 +241,10 @@ def _format_verbose_error(self, message=None):
244241 # read whole file
245242 lines = _f .read ().decode ('utf-8' )
246243
247- # append contents
248- error_text += u"{}: \n ---- \n {} \n " . format ( f , lines )
244+ # fill dict
245+ result [ f ] = lines
249246
250- return error_text
247+ return result
251248
252249 def init (self ,
253250 fsync = False ,
@@ -429,7 +426,8 @@ def get_pid(self):
429426 """
430427
431428 if self .status ():
432- with io .open (os .path .join (self .data_dir , 'postmaster.pid' )) as f :
429+ pid_file = os .path .join (self .data_dir , 'postmaster.pid' )
430+ with io .open (pid_file ) as f :
433431 return int (f .readline ())
434432
435433 # for clarity
@@ -478,8 +476,9 @@ def start(self, params=[]):
478476 try :
479477 execute_utility (_params , self .utils_log_name )
480478 except ExecUtilException as e :
481- msg = self ._format_verbose_error ('Cannot start node' )
482- raise_from (StartNodeException (msg ), e )
479+ msg = 'Cannot start node'
480+ files = self ._collect_special_files ()
481+ raise_from (StartNodeException (msg , files ), e )
483482
484483 self ._maybe_start_logger ()
485484
@@ -533,8 +532,9 @@ def restart(self, params=[]):
533532 try :
534533 execute_utility (_params , self .utils_log_name )
535534 except ExecUtilException as e :
536- msg = self ._format_verbose_error ('Cannot restart node' )
537- raise_from (StartNodeException (msg ), e )
535+ msg = 'Cannot restart node'
536+ files = self ._collect_special_files ()
537+ raise_from (StartNodeException (msg , files ), e )
538538
539539 self ._maybe_start_logger ()
540540
@@ -695,7 +695,7 @@ def safe_psql(self,
695695 username = username ,
696696 input = input )
697697 if ret :
698- raise QueryException ((err or b'' ).decode ('utf-8' ))
698+ raise QueryException ((err or b'' ).decode ('utf-8' ), query )
699699
700700 return out
701701
@@ -793,13 +793,13 @@ def poll_query_until(self,
793793 return # done
794794
795795 if res is None :
796- raise QueryException ('Query returned None' )
796+ raise QueryException ('Query returned None' , query )
797797
798798 if len (res ) == 0 :
799- raise QueryException ('Query returned 0 rows' )
799+ raise QueryException ('Query returned 0 rows' , query )
800800
801801 if len (res [0 ]) == 0 :
802- raise QueryException ('Query returned 0 columns' )
802+ raise QueryException ('Query returned 0 columns' , query )
803803
804804 if res [0 ][0 ] == expected :
805805 return # done
@@ -916,7 +916,7 @@ def catchup(self, dbname=None, username=None):
916916 username = username ,
917917 max_attempts = 0 ) # infinite
918918 except Exception as e :
919- raise_from (CatchUpException (' Failed to catch up' ), e )
919+ raise_from (CatchUpException (" Failed to catch up" , poll_lsn ), e )
920920
921921 def pgbench (self ,
922922 dbname = None ,
0 commit comments