diff --git a/src/bin/gs_guc/cluster_guc.conf b/src/bin/gs_guc/cluster_guc.conf index 9726396ca..9e7af9293 100644 --- a/src/bin/gs_guc/cluster_guc.conf +++ b/src/bin/gs_guc/cluster_guc.conf @@ -525,6 +525,7 @@ defer_csn_cleanup_time|int|0,2147483647|ms|NULL| tcp_recv_timeout|int|0,86400|s|Specify the receiving timeouts until reporting an error.| max_inner_tool_connections|int|1,8388607|NULL|NULL| max_keep_log_seg|int|0,2147483647|NULL|NULL| +max_background_workers|int|0,262143|NULL|NULL| [gtm] nodename|string|0,0|NULL|Name of this GTM/GTM-Standby.| port|int|1,65535|NULL|Listen Port of GTM or GTM standby server.| diff --git a/src/common/backend/utils/init/miscinit.cpp b/src/common/backend/utils/init/miscinit.cpp index 3e58554e3..7a6d083d9 100755 --- a/src/common/backend/utils/init/miscinit.cpp +++ b/src/common/backend/utils/init/miscinit.cpp @@ -804,7 +804,7 @@ void InitializeSessionUserId(const char* role_name, Oid role_id) if (!rform->rolcanlogin) { ereport(FATAL, (errcode(ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION), - errmsg("role \"%s\" is not permitted to login", role_name))); + errmsg("role \"%s\" is not permitted to login", rname))); } /* * Check connection limit for this role. @@ -818,17 +818,17 @@ void InitializeSessionUserId(const char* role_name, Oid role_id) */ if (rform->rolconnlimit >= 0 && !u_sess->misc_cxt.AuthenticatedUserIsSuperuser && CountUserBackends(role_id) > rform->rolconnlimit) { - ReportAlarmTooManyDbUserConn(role_name); + ReportAlarmTooManyDbUserConn(rname); ereport(FATAL, - (errcode(ERRCODE_TOO_MANY_CONNECTIONS), errmsg("too many connections for role \"%s\"", role_name))); + (errcode(ERRCODE_TOO_MANY_CONNECTIONS), errmsg("too many connections for role \"%s\"", rname))); } else if (!u_sess->misc_cxt.AuthenticatedUserIsSuperuser) { - ReportResumeTooManyDbUserConn(role_name); + ReportResumeTooManyDbUserConn(rname); } } /* Record username and superuser status as GUC settings too */ - SetConfigOption("session_authorization", role_name, PGC_BACKEND, PGC_S_OVERRIDE); + SetConfigOption("session_authorization", rname, PGC_BACKEND, PGC_S_OVERRIDE); SetConfigOption( "is_sysadmin", u_sess->misc_cxt.AuthenticatedUserIsSuperuser ? "on" : "off", PGC_INTERNAL, PGC_S_OVERRIDE); diff --git a/src/gausskernel/process/postmaster/bgworker.cpp b/src/gausskernel/process/postmaster/bgworker.cpp index a254d2062..3951f5726 100644 --- a/src/gausskernel/process/postmaster/bgworker.cpp +++ b/src/gausskernel/process/postmaster/bgworker.cpp @@ -32,6 +32,8 @@ #include "utils/ascii.h" #include "utils/ps_status.h" #include "utils/postinit.h" +#include "access/xact.h" +#include "utils/memtrack.h" /* * BackgroundWorkerSlots exist in shared memory and can be accessed (via @@ -675,6 +677,7 @@ void StartBackgroundWorker(void* bgWorkerSlotShmAddr) BackgroundWorker *worker = t_thrd.bgworker_cxt.my_bgworker_entry; bgworker_main_type entrypt; + t_thrd.proc_cxt.MyProgName = "BackgroundWorker"; /* * Create memory context and buffer used for RowDescription messages. As * SendRowDescriptionMessage(), via exec_describe_statement_message(), is @@ -755,9 +758,13 @@ void StartBackgroundWorker(void* bgWorkerSlotShmAddr) /* Prevent interrupts while cleaning up */ HOLD_INTERRUPTS(); + /* output the memory tracking information when error happened */ + MemoryTrackingOutputFile(); + /* Report the error to the server log */ EmitErrorReport(); + AbortCurrentTransaction(); /* * Do we need more cleanup here? For shmem-connected bgworkers, we * will call InitProcess below, which will install ProcKill as exit @@ -795,6 +802,9 @@ void StartBackgroundWorker(void* bgWorkerSlotShmAddr) #endif } + /* Initialize the memory tracking information */ + MemoryTrackingInit(); + /* * Look up the entry point function, loading its library if necessary. */