Hi,

Currently

  Max(lock_addin_request, NUM_USER_DEFINED_LWLOCKS);

LWLock's are added during startup for extensions.

However, this presents a problem if an extension doesn't specify the correct number of LWLock's needed, if the total number is <= 4.

The attached patch requires extensions to specify the correct number of LWLock's needed. This change will break extensions that specifies an incorrect number, but makes it easier to debug which extension which is at fault.

Probably too big a change though. Maybe a patch against xfunc.sgml is better ?

Best regards,
  Jesper

*** /tmp/a5ON4C_lwlock.c	2015-07-31 11:23:46.424947872 -0400
--- src/backend/storage/lmgr/lwlock.c	2015-07-31 11:22:49.664973520 -0400
***************
*** 364,375 ****
  	numLocks += max_replication_slots;
  
  	/*
! 	 * Add any requested by loadable modules; for backwards-compatibility
! 	 * reasons, allocate at least NUM_USER_DEFINED_LWLOCKS of them even if
! 	 * there are no explicit requests.
  	 */
  	lock_addin_request_allowed = false;
! 	numLocks += Max(lock_addin_request, NUM_USER_DEFINED_LWLOCKS);
  
  	return numLocks;
  }
--- 364,378 ----
  	numLocks += max_replication_slots;
  
  	/*
! 	 * Add any requested by loadable modules by the explicit requested number.
! 	 * For backwards-compatibility reasons, allocate at least
! 	 * NUM_USER_DEFINED_LWLOCKS of them even if there are no explicit requests.
  	 */
  	lock_addin_request_allowed = false;
! 	if (lock_addin_request > 0)
! 		numLocks += lock_addin_request;
! 	else
! 		numLocks += NUM_USER_DEFINED_LWLOCKS;
  
  	return numLocks;
  }

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to