@@ -649,6 +649,13 @@ jsonbd_worker_main(Datum arg)
649
649
worker_num = worker_args -> worker_num ;
650
650
dboid = worker_args -> dboid ;
651
651
652
+ /* Connect to our database */
653
+ BackgroundWorkerInitializeConnectionByOid (dboid , InvalidOid );
654
+
655
+ /* Create resource owner */
656
+ CurrentResourceOwner = ResourceOwnerCreate (NULL , "jsonbd_worker" );
657
+ init_local_variables (worker_num , dboid );
658
+
652
659
/* We don't need this segment anymore */
653
660
dsm_detach (seg );
654
661
@@ -662,13 +669,6 @@ jsonbd_worker_main(Datum arg)
662
669
/* Set launcher free */
663
670
SetLatch (& starter -> procLatch );
664
671
665
- /* Connect to our database */
666
- BackgroundWorkerInitializeConnectionByOid (dboid , InvalidOid );
667
-
668
- /* Create resource owner */
669
- CurrentResourceOwner = ResourceOwnerCreate (NULL , "jsonbd_worker" );
670
- init_local_variables (worker_num , dboid );
671
-
672
672
MemoryContextSwitchTo (worker_context );
673
673
674
674
while (true)
@@ -791,19 +791,14 @@ jsonbd_register_worker(int worker_num, Oid dboid)
791
791
worker .bgw_notify_pid = MyProcPid ;
792
792
memcpy (worker .bgw_library_name , "jsonbd" , BGW_MAXLEN );
793
793
memcpy (worker .bgw_function_name , CppAsString (jsonbd_worker_main ), BGW_MAXLEN );
794
-
795
- /* we need transaction to access syscache */
796
- start_xact_command ();
797
- snprintf (worker .bgw_name , BGW_MAXLEN , "jsonbd, worker %d, db: \"%s\"" ,
798
- worker_num , get_database_name (dboid ));
799
- finish_xact_command ();
800
-
794
+ snprintf (worker .bgw_name , BGW_MAXLEN , "jsonbd, worker %d, db: %d" ,
795
+ worker_num , dboid );
801
796
worker .bgw_main_arg = UInt32GetDatum (dsm_segment_handle (seg ));
802
797
803
798
/* Start dynamic worker */
804
799
if (!RegisterDynamicBackgroundWorker (& worker , & bgw_handle ))
805
800
{
806
- elog (LOG , "jsonbd: cannot start dictionary worker" );
801
+ elog (LOG , "jsonbd: could not start dictionary worker" );
807
802
return false;
808
803
}
809
804
0 commit comments