git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0464f25)
Move TRACE calls into WaitOnLock()
Mon, 4 Nov 2024 14:21:01 +0000 (16:21 +0200)
Mon, 4 Nov 2024 14:21:01 +0000 (16:21 +0200)
LockAcquire is a long and complex function. Pushing more stuff to its
subroutines makes it a little more manageable.

Reviewed-by: Maxim Orlov
Discussion: https://www.postgresql.org/message-id/7c2090cd-a72a-4e34-afaa-6dd2ef31440e@iki.fi


diff --git a/src/backend/storage/lmgr/lock.c b/src/backend/storage/lmgr/lock.c
index 8abd9837293fb7c4245fbb380f1c9100d832b49f..cee3f03c4b063a2422935e3125cd80057b4fdf60 100644 (file)
--- a/src/backend/storage/lmgr/lock.c
+++ b/src/backend/storage/lmgr/lock.c
@@ -1100,23 +1100,8 @@ LockAcquireExtended(const LOCKTAG *locktag,
* case, because while trying to go to sleep, we may discover that we
* can acquire the lock immediately after all.
*/
-
- TRACE_POSTGRESQL_LOCK_WAIT_START(locktag->locktag_field1,
- locktag->locktag_field2,
- locktag->locktag_field3,
- locktag->locktag_field4,
- locktag->locktag_type,
- lockmode);
-
WaitOnLock(locallock, owner, dontWait);
- TRACE_POSTGRESQL_LOCK_WAIT_DONE(locktag->locktag_field1,
- locktag->locktag_field2,
- locktag->locktag_field3,
- locktag->locktag_field4,
- locktag->locktag_type,
- lockmode);
-
/*
* NOTE: do not do any material change of state between here and
* return. All required changes in locktable state must have been
@@ -1860,6 +1845,13 @@ WaitOnLock(LOCALLOCK *locallock, ResourceOwner owner, bool dontWait)
LOCKMETHODID lockmethodid = LOCALLOCK_LOCKMETHOD(*locallock);
LockMethod lockMethodTable = LockMethods[lockmethodid];
+ TRACE_POSTGRESQL_LOCK_WAIT_START(locallock->tag.lock.locktag_field1,
+ locallock->tag.lock.locktag_field2,
+ locallock->tag.lock.locktag_field3,
+ locallock->tag.lock.locktag_field4,
+ locallock->tag.lock.locktag_type,
+ locallock->tag.mode);
+
LOCK_PRINT("WaitOnLock: sleeping on lock",
locallock->lock, locallock->tag.mode);
@@ -1932,6 +1924,13 @@ WaitOnLock(LOCALLOCK *locallock, ResourceOwner owner, bool dontWait)
LOCK_PRINT("WaitOnLock: wakeup on lock",
locallock->lock, locallock->tag.mode);
+
+ TRACE_POSTGRESQL_LOCK_WAIT_DONE(locallock->tag.lock.locktag_field1,
+ locallock->tag.lock.locktag_field2,
+ locallock->tag.lock.locktag_field3,
+ locallock->tag.lock.locktag_field4,
+ locallock->tag.lock.locktag_type,
+ locallock->tag.mode);
}
/*
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /