@@ -440,63 +440,47 @@ collector_main(Datum main_arg)
440440 LockAcquire (& tag , ExclusiveLock , false, false);
441441 collector_hdr -> request = NO_REQUEST ;
442442
443- /*
444- * XXX: it is very likely that this TRY/CATCH is useless. If any
445- * error occurs, collector's bgworker will exit cancelling the lock.
446- *
447- * TODO: thus, consider reverting commit e6f52a7547a15.
448- */
449- PG_TRY ();
443+ if (request == HISTORY_REQUEST || request == PROFILE_REQUEST )
450444 {
451- if (request == HISTORY_REQUEST || request == PROFILE_REQUEST )
452- {
453- shm_mq_result mq_result ;
454-
455- /* Send history or profile */
456- shm_mq_set_sender (collector_mq , MyProc );
457- mqh = shm_mq_attach (collector_mq , NULL , NULL );
458- mq_result = shm_mq_wait_for_attach (mqh );
459- switch (mq_result )
460- {
461- case SHM_MQ_SUCCESS :
462- switch (request )
463- {
464- case HISTORY_REQUEST :
465- send_history (& observations , mqh );
466- break ;
467- case PROFILE_REQUEST :
468- send_profile (profile_hash , mqh );
469- break ;
470- default :
471- AssertState (false);
472- }
473- break ;
474- case SHM_MQ_DETACHED :
475- ereport (WARNING ,
476- (errmsg ("pg_wait_sampling collector: "
477- "receiver of message queue has been "
478- "detached" )));
479- break ;
480- default :
481- AssertState (false);
482- }
483- shm_mq_detach_compat (mqh , collector_mq );
484- }
485- else if (request == PROFILE_RESET )
445+ shm_mq_result mq_result ;
446+
447+ /* Send history or profile */
448+ shm_mq_set_sender (collector_mq , MyProc );
449+ mqh = shm_mq_attach (collector_mq , NULL , NULL );
450+ mq_result = shm_mq_wait_for_attach (mqh );
451+ switch (mq_result )
486452 {
487- /* Reset profile hash */
488- hash_destroy (profile_hash );
489- profile_hash = make_profile_hash ();
453+ case SHM_MQ_SUCCESS :
454+ switch (request )
455+ {
456+ case HISTORY_REQUEST :
457+ send_history (& observations , mqh );
458+ break ;
459+ case PROFILE_REQUEST :
460+ send_profile (profile_hash , mqh );
461+ break ;
462+ default :
463+ AssertState (false);
464+ }
465+ break ;
466+ case SHM_MQ_DETACHED :
467+ ereport (WARNING ,
468+ (errmsg ("pg_wait_sampling collector: "
469+ "receiver of message queue have been "
470+ "detached" )));
471+ break ;
472+ default :
473+ AssertState (false);
490474 }
491-
492- LockRelease (& tag , ExclusiveLock , false);
475+ shm_mq_detach_compat (mqh , collector_mq );
493476 }
494- PG_CATCH ();
477+ else if ( request == PROFILE_RESET )
495478 {
496- LockRelease (& tag , ExclusiveLock , false);
497- PG_RE_THROW ();
479+ /* Reset profile hash */
480+ hash_destroy (profile_hash );
481+ profile_hash = make_profile_hash ();
498482 }
499- PG_END_TRY ( );
483+ LockRelease ( & tag , ExclusiveLock , false );
500484 }
501485 }
502486
0 commit comments