pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #17591: elog(ERROR) cause SharedSnapshotLock deadlock
3+ messages / 3 participants
[nested] [flat]

* BUG #17591: elog(ERROR) cause SharedSnapshotLock deadlock
@ 2022-08-22 06:23  PG Bug reporting form <noreply@postgresql.org>
  0 siblings, 2 replies; 3+ messages in thread

From: PG Bug reporting form @ 2022-08-22 06:23 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: ma100@hotmail.com

The following bug has been logged on the website:

Bug reference:      17591
Logged by:          ma liangzhu
Email address:      ma100@hotmail.com
PostgreSQL version: 14.5
Operating system:   centos7
Description:        

in lock.c, we can see code  Release lock before return	, e.g.

```c
996: LockAcquireExtended
{ 
	LWLockAcquire(partitionLock, LW_EXCLUSIVE);
 
	proclock = SetupLockInTable( );
	if (!proclock)
	{	 
		LWLockRelease(partitionLock);  --- Release lock before return	 
		ereport(ERROR,)
	}
}
```

bug we can see some code doesn't release the lock. Does it may cause
deadlock?

```c
LockRelease()
{
	LWLockAcquire(partitionLock, LW_EXCLUSIVE);
 
	lock = locallock->lock;
	if (!lock)
	{ 
		lock = (LOCK *) hash_search_with_hash_value( );
		if (!lock)
2126:			elog(ERROR, "failed to re-find shared lock object");  -- exit
without release
	}
```



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #17591: elog(ERROR) cause SharedSnapshotLock deadlock
@ 2022-08-22 07:45  Zhang Mingli <zmlpostgres@gmail.com>
  parent: PG Bug reporting form <noreply@postgresql.org>
  1 sibling, 0 replies; 3+ messages in thread

From: Zhang Mingli @ 2022-08-22 07:45 UTC (permalink / raw)
  To: ma100@hotmail.com; pgsql-bugs@lists.postgresql.org

Hi,

Didn’t see any bugs here, it report an error and the transaction will end and release all resources.

Regards,
Zhang Mingli
On Aug 22, 2022, 14:58 +0800, PG Bug reporting form <noreply@postgresql.org>, wrote:
> The following bug has been logged on the website:
>
> Bug reference: 17591
> Logged by: ma liangzhu
> Email address: ma100@hotmail.com
> PostgreSQL version: 14.5
> Operating system: centos7
> Description:
>
> in lock.c, we can see code Release lock before return , e.g.
>
> ```c
> 996: LockAcquireExtended
> {
> LWLockAcquire(partitionLock, LW_EXCLUSIVE);
>
> proclock = SetupLockInTable( );
> if (!proclock)
> {
> LWLockRelease(partitionLock); --- Release lock before return
> ereport(ERROR,)
> }
> }
> ```
>
> bug we can see some code doesn't release the lock. Does it may cause
> deadlock?
>
> ```c
> LockRelease()
> {
> LWLockAcquire(partitionLock, LW_EXCLUSIVE);
>
> lock = locallock->lock;
> if (!lock)
> {
> lock = (LOCK *) hash_search_with_hash_value( );
> if (!lock)
> 2126: elog(ERROR, "failed to re-find shared lock object"); -- exit
> without release
> }
> ```
>

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #17591: elog(ERROR) cause SharedSnapshotLock deadlock
@ 2022-08-22 13:13  Tom Lane <tgl@sss.pgh.pa.us>
  parent: PG Bug reporting form <noreply@postgresql.org>
  1 sibling, 0 replies; 3+ messages in thread

From: Tom Lane @ 2022-08-22 13:13 UTC (permalink / raw)
  To: ma100@hotmail.com; +Cc: pgsql-bugs@lists.postgresql.org

PG Bug reporting form <noreply@postgresql.org> writes:
> in lock.c, we can see code  Release lock before return	, e.g.
> ...
> bug we can see some code doesn't release the lock. Does it may cause
> deadlock?

Transaction cleanup will automatically release all locks (and other
resources too).  So the places that do a manual release before
elog(ERROR) are something of a waste of code space.  It might be worth
doing that if you're concerned about holding the lock for the minimum
possible amount of time; but usually that's only a consideration for
very heavily-contended spinlocks or LWLocks.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2022-08-22 13:13 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-08-22 06:23 BUG #17591: elog(ERROR) cause SharedSnapshotLock deadlock PG Bug reporting form <noreply@postgresql.org>
2022-08-22 07:45 ` Zhang Mingli <zmlpostgres@gmail.com>
2022-08-22 13:13 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox