diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c index 9de5239524..82b2f3e146 100644 --- a/src/backend/access/transam/parallel.c +++ b/src/backend/access/transam/parallel.c @@ -1148,15 +1148,6 @@ ParallelWorkerMain(Datum main_arg) fps->parallel_master_pid)) return; - /* - * Load libraries that were loaded by original backend. We want to do - * this before restoring GUCs, because the libraries might define custom - * variables. - */ - libraryspace = shm_toc_lookup(toc, PARALLEL_KEY_LIBRARY); - Assert(libraryspace != NULL); - RestoreLibraryState(libraryspace); - /* * Identify the entry point to be called. In theory this could result in * loading an additional library, though most likely the entry point is in @@ -1186,10 +1177,19 @@ ParallelWorkerMain(Datum main_arg) */ SetClientEncoding(GetDatabaseEncoding()); + /* + * Load libraries that were loaded by original backend. We want to do + * this before restoring GUCs, because the libraries might define custom + * variables. + */ + libraryspace = shm_toc_lookup(toc, PARALLEL_KEY_LIBRARY); + Assert(libraryspace != NULL); + StartTransactionCommand(); + RestoreLibraryState(libraryspace); + /* Restore GUC values from launching backend. */ gucspace = shm_toc_lookup(toc, PARALLEL_KEY_GUC); Assert(gucspace != NULL); - StartTransactionCommand(); RestoreGUCState(gucspace); CommitTransactionCommand();