@@ -816,6 +816,15 @@ pg_wait_sampling_reset_profile(PG_FUNCTION_ARGS)
816816 */
817817 check_shmem ();
818818
819+ pgws_init_lock_tag (& queueTag , PGWS_QUEUE_LOCK );
820+
821+ LockAcquire (& queueTag , ExclusiveLock , false, false);
822+
823+ pgws_init_lock_tag (& collectorTag , PGWS_COLLECTOR_LOCK );
824+ LockAcquire (& collectorTag , ExclusiveLock , false, false);
825+ pgws_collector_hdr -> request = PROFILE_RESET ;
826+ LockRelease (& collectorTag , ExclusiveLock , false);
827+
819828 /* The collector may have not started yet (it'd be a
820829 * race condition with background worker startup to
821830 * use latch without a check here).
@@ -828,15 +837,6 @@ pg_wait_sampling_reset_profile(PG_FUNCTION_ARGS)
828837 ereport (ERROR , (errcode (ERRCODE_INTERNAL_ERROR ),
829838 errmsg ("pg_wait_sampling collector wasn't started" )));
830839
831- pgws_init_lock_tag (& queueTag , PGWS_QUEUE_LOCK );
832-
833- LockAcquire (& queueTag , ExclusiveLock , false, false);
834-
835- pgws_init_lock_tag (& collectorTag , PGWS_COLLECTOR_LOCK );
836- LockAcquire (& collectorTag , ExclusiveLock , false, false);
837- pgws_collector_hdr -> request = PROFILE_RESET ;
838- LockRelease (& collectorTag , ExclusiveLock , false);
839-
840840 SetLatch (pgws_collector_hdr -> latch );
841841
842842 LockRelease (& queueTag , ExclusiveLock , false);
0 commit comments