max_pred_locks_per_transaction-2.patch

text/plain

Filename: max_pred_locks_per_transaction-2.patch
Type: text/plain
Part: 0
Message: Re: Add support for logging the current role

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: context
File+
doc/src/sgml/config.sgml 4 0
src/backend/storage/lmgr/predicate.c 5 0
src/backend/utils/misc/guc.c 2 0
src/backend/utils/misc/postgresql.conf.sample 1 1
*** a/doc/src/sgml/config.sgml
--- b/doc/src/sgml/config.sgml
***************
*** 5188,5202 **** dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir'
        </listitem>
       </varlistentry>
  
!      <varlistentry id="guc-max-predicate-locks-per-transaction" xreflabel="max_predicate_locks_per_transaction">
!       <term><varname>max_predicate_locks_per_transaction</varname> (<type>integer</type>)</term>
        <indexterm>
!        <primary><varname>max_predicate_locks_per_transaction</> configuration parameter</primary>
        </indexterm>
        <listitem>
         <para>
          The shared predicate lock table tracks locks on
!         <varname>max_predicate_locks_per_transaction</varname> * (<xref
          linkend="guc-max-connections"> + <xref
          linkend="guc-max-prepared-transactions">) objects (e.g., tables);
          hence, no more than this many distinct objects can be locked at
--- 5188,5202 ----
        </listitem>
       </varlistentry>
  
!      <varlistentry id="guc-max-pred-locks-per-transaction" xreflabel="max_pred_locks_per_transaction">
!       <term><varname>max_pred_locks_per_transaction</varname> (<type>integer</type>)</term>
        <indexterm>
!        <primary><varname>max_pred_locks_per_transaction</> configuration parameter</primary>
        </indexterm>
        <listitem>
         <para>
          The shared predicate lock table tracks locks on
!         <varname>max_pred_locks_per_transaction</varname> * (<xref
          linkend="guc-max-connections"> + <xref
          linkend="guc-max-prepared-transactions">) objects (e.g., tables);
          hence, no more than this many distinct objects can be locked at
*** a/src/backend/storage/lmgr/predicate.c
--- b/src/backend/storage/lmgr/predicate.c
***************
*** 1874,1880 **** DeleteChildTargetLocks(const PREDICATELOCKTARGETTAG *newtargettag)
   * thresholds are, either making it proportional to the number of
   * tuples in a page & pages in a relation, or at least making it a
   * GUC. Currently the threshold is 3 for a page lock, and
!  * max_predicate_locks_per_transaction/2 for a relation lock, chosen
   * entirely arbitrarily (and without benchmarking).
   */
  static int
--- 1874,1880 ----
   * thresholds are, either making it proportional to the number of
   * tuples in a page & pages in a relation, or at least making it a
   * GUC. Currently the threshold is 3 for a page lock, and
!  * max_pred_locks_per_transaction/2 for a relation lock, chosen
   * entirely arbitrarily (and without benchmarking).
   */
  static int
***************
*** 2063,2069 **** CreatePredicateLock(const PREDICATELOCKTARGETTAG *targettag,
  		ereport(ERROR,
  				(errcode(ERRCODE_OUT_OF_MEMORY),
  				 errmsg("out of shared memory"),
! 				 errhint("You might need to increase max_predicate_locks_per_transaction.")));
  	if (!found)
  	{
  		SHMQueueInit(&(target->predicateLocks));
--- 2063,2069 ----
  		ereport(ERROR,
  				(errcode(ERRCODE_OUT_OF_MEMORY),
  				 errmsg("out of shared memory"),
! 				 errhint("You might need to increase max_pred_locks_per_transaction.")));
  	if (!found)
  	{
  		SHMQueueInit(&(target->predicateLocks));
***************
*** 2082,2088 **** CreatePredicateLock(const PREDICATELOCKTARGETTAG *targettag,
  		ereport(ERROR,
  				(errcode(ERRCODE_OUT_OF_MEMORY),
  				 errmsg("out of shared memory"),
! 				 errhint("You might need to increase max_predicate_locks_per_transaction.")));
  
  	if (!found)
  	{
--- 2082,2088 ----
  		ereport(ERROR,
  				(errcode(ERRCODE_OUT_OF_MEMORY),
  				 errmsg("out of shared memory"),
! 				 errhint("You might need to increase max_pred_locks_per_transaction.")));
  
  	if (!found)
  	{
***************
*** 2341,2347 **** PredicateLockTupleRowVersionLink(const Relation relation,
  			ereport(ERROR,
  					(errcode(ERRCODE_OUT_OF_MEMORY),
  					 errmsg("out of shared memory"),
! 					 errhint("You might need to increase max_predicate_locks_per_transaction.")));
  		if (!found)
  		{
  			SHMQueueInit(&(newtarget->predicateLocks));
--- 2341,2347 ----
  			ereport(ERROR,
  					(errcode(ERRCODE_OUT_OF_MEMORY),
  					 errmsg("out of shared memory"),
! 					 errhint("You might need to increase max_pred_locks_per_transaction.")));
  		if (!found)
  		{
  			SHMQueueInit(&(newtarget->predicateLocks));
***************
*** 3337,3343 **** ReleaseOneSerializableXact(SERIALIZABLEXACT *sxact, bool partial,
  				ereport(ERROR,
  						(errcode(ERRCODE_OUT_OF_MEMORY),
  						 errmsg("out of shared memory"),
! 						 errhint("You might need to increase max_predicate_locks_per_transaction.")));
  			if (found)
  			{
  				if (predlock->commitSeqNo < sxact->commitSeqNo)
--- 3337,3343 ----
  				ereport(ERROR,
  						(errcode(ERRCODE_OUT_OF_MEMORY),
  						 errmsg("out of shared memory"),
! 						 errhint("You might need to increase max_pred_locks_per_transaction.")));
  			if (found)
  			{
  				if (predlock->commitSeqNo < sxact->commitSeqNo)
*** a/src/backend/utils/misc/guc.c
--- b/src/backend/utils/misc/guc.c
***************
*** 1725,1734 **** static struct config_int ConfigureNamesInt[] =
  	},
  
  	{
! 		{"max_predicate_locks_per_transaction", PGC_POSTMASTER, LOCK_MANAGEMENT,
  			gettext_noop("Sets the maximum number of predicate locks per transaction."),
  			gettext_noop("The shared predicate lock table is sized on the assumption that "
! 			  "at most max_predicate_locks_per_transaction * max_connections distinct "
  						 "objects will need to be locked at any one time.")
  		},
  		&max_predicate_locks_per_xact,
--- 1725,1734 ----
  	},
  
  	{
! 		{"max_pred_locks_per_transaction", PGC_POSTMASTER, LOCK_MANAGEMENT,
  			gettext_noop("Sets the maximum number of predicate locks per transaction."),
  			gettext_noop("The shared predicate lock table is sized on the assumption that "
! 			  "at most max_pred_locks_per_transaction * max_connections distinct "
  						 "objects will need to be locked at any one time.")
  		},
  		&max_predicate_locks_per_xact,
*** a/src/backend/utils/misc/postgresql.conf.sample
--- b/src/backend/utils/misc/postgresql.conf.sample
***************
*** 503,509 ****
  # Note:  Each lock table slot uses ~270 bytes of shared memory, and there are
  # max_locks_per_transaction * (max_connections + max_prepared_transactions)
  # lock table slots.
! #max_predicate_locks_per_transaction = 64	# min 10
  					# (change requires restart)
  
  #------------------------------------------------------------------------------
--- 503,509 ----
  # Note:  Each lock table slot uses ~270 bytes of shared memory, and there are
  # max_locks_per_transaction * (max_connections + max_prepared_transactions)
  # lock table slots.
! #max_pred_locks_per_transaction = 64	# min 10
  					# (change requires restart)
  
  #------------------------------------------------------------------------------