@@ -98,7 +98,8 @@ static void MultiXactIdWait(MultiXactId multi, MultiXactStatus status, uint16 in
9898 Relation rel , ItemPointer ctid , XLTW_Oper oper ,
9999 int * remaining );
100100static bool ConditionalMultiXactIdWait (MultiXactId multi , MultiXactStatus status ,
101- uint16 infomask , Relation rel , int * remaining );
101+ uint16 infomask , Relation rel , int * remaining ,
102+ bool logLockFailure );
102103static void index_delete_sort (TM_IndexDeleteOp * delstate );
103104static int bottomup_sort_and_shrink (TM_IndexDeleteOp * delstate );
104105static XLogRecPtr log_heap_new_cid (Relation relation , HeapTuple tup );
@@ -162,8 +163,8 @@ static const struct
162163 LockTuple((rel), (tup), tupleLockExtraInfo[mode].hwlock)
163164#define UnlockTupleTuplock (rel , tup , mode ) \
164165 UnlockTuple((rel), (tup), tupleLockExtraInfo[mode].hwlock)
165- #define ConditionalLockTupleTuplock (rel , tup , mode ) \
166- ConditionalLockTuple((rel), (tup), tupleLockExtraInfo[mode].hwlock)
166+ #define ConditionalLockTupleTuplock (rel , tup , mode , log ) \
167+ ConditionalLockTuple((rel), (tup), tupleLockExtraInfo[mode].hwlock, (log) )
167168
168169#ifdef USE_PREFETCH
169170/*
@@ -4894,7 +4895,7 @@ heap_lock_tuple(Relation relation, HeapTuple tuple,
48944895 case LockWaitSkip :
48954896 if (!ConditionalMultiXactIdWait ((MultiXactId ) xwait ,
48964897 status , infomask , relation ,
4897- NULL ))
4898+ NULL , false ))
48984899 {
48994900 result = TM_WouldBlock ;
49004901 /* recovery code expects to have buffer lock held */
@@ -4905,7 +4906,7 @@ heap_lock_tuple(Relation relation, HeapTuple tuple,
49054906 case LockWaitError :
49064907 if (!ConditionalMultiXactIdWait ((MultiXactId ) xwait ,
49074908 status , infomask , relation ,
4908- NULL ))
4909+ NULL , log_lock_failure ))
49094910 ereport (ERROR ,
49104911 (errcode (ERRCODE_LOCK_NOT_AVAILABLE ),
49114912 errmsg ("could not obtain lock on row in relation \"%s\"" ,
@@ -4934,7 +4935,7 @@ heap_lock_tuple(Relation relation, HeapTuple tuple,
49344935 XLTW_Lock );
49354936 break ;
49364937 case LockWaitSkip :
4937- if (!ConditionalXactLockTableWait (xwait ))
4938+ if (!ConditionalXactLockTableWait (xwait , false ))
49384939 {
49394940 result = TM_WouldBlock ;
49404941 /* recovery code expects to have buffer lock held */
@@ -4943,7 +4944,7 @@ heap_lock_tuple(Relation relation, HeapTuple tuple,
49434944 }
49444945 break ;
49454946 case LockWaitError :
4946- if (!ConditionalXactLockTableWait (xwait ))
4947+ if (!ConditionalXactLockTableWait (xwait , log_lock_failure ))
49474948 ereport (ERROR ,
49484949 (errcode (ERRCODE_LOCK_NOT_AVAILABLE ),
49494950 errmsg ("could not obtain lock on row in relation \"%s\"" ,
@@ -5203,12 +5204,12 @@ heap_acquire_tuplock(Relation relation, ItemPointer tid, LockTupleMode mode,
52035204 break ;
52045205
52055206 case LockWaitSkip :
5206- if (!ConditionalLockTupleTuplock (relation , tid , mode ))
5207+ if (!ConditionalLockTupleTuplock (relation , tid , mode , false ))
52075208 return false;
52085209 break ;
52095210
52105211 case LockWaitError :
5211- if (!ConditionalLockTupleTuplock (relation , tid , mode ))
5212+ if (!ConditionalLockTupleTuplock (relation , tid , mode , log_lock_failure ))
52125213 ereport (ERROR ,
52135214 (errcode (ERRCODE_LOCK_NOT_AVAILABLE ),
52145215 errmsg ("could not obtain lock on row in relation \"%s\"" ,
@@ -7581,7 +7582,8 @@ DoesMultiXactIdConflict(MultiXactId multi, uint16 infomask,
75817582 * fail if lock is unavailable. 'rel', 'ctid' and 'oper' are used to set up
75827583 * context information for error messages. 'remaining', if not NULL, receives
75837584 * the number of members that are still running, including any (non-aborted)
7584- * subtransactions of our own transaction.
7585+ * subtransactions of our own transaction. 'logLockFailure' indicates whether
7586+ * to log details when a lock acquisition fails with 'nowait' enabled.
75857587 *
75867588 * We do this by sleeping on each member using XactLockTableWait. Any
75877589 * members that belong to the current backend are *not* waited for, however;
@@ -7602,7 +7604,7 @@ static bool
76027604Do_MultiXactIdWait (MultiXactId multi , MultiXactStatus status ,
76037605 uint16 infomask , bool nowait ,
76047606 Relation rel , ItemPointer ctid , XLTW_Oper oper ,
7605- int * remaining )
7607+ int * remaining , bool logLockFailure )
76067608{
76077609 bool result = true;
76087610 MultiXactMember * members ;
@@ -7649,7 +7651,7 @@ Do_MultiXactIdWait(MultiXactId multi, MultiXactStatus status,
76497651 */
76507652 if (nowait )
76517653 {
7652- result = ConditionalXactLockTableWait (memxid );
7654+ result = ConditionalXactLockTableWait (memxid , logLockFailure );
76537655 if (!result )
76547656 break ;
76557657 }
@@ -7682,7 +7684,7 @@ MultiXactIdWait(MultiXactId multi, MultiXactStatus status, uint16 infomask,
76827684 int * remaining )
76837685{
76847686 (void ) Do_MultiXactIdWait (multi , status , infomask , false,
7685- rel , ctid , oper , remaining );
7687+ rel , ctid , oper , remaining , false );
76867688}
76877689
76887690/*
@@ -7700,10 +7702,11 @@ MultiXactIdWait(MultiXactId multi, MultiXactStatus status, uint16 infomask,
77007702 */
77017703static bool
77027704ConditionalMultiXactIdWait (MultiXactId multi , MultiXactStatus status ,
7703- uint16 infomask , Relation rel , int * remaining )
7705+ uint16 infomask , Relation rel , int * remaining ,
7706+ bool logLockFailure )
77047707{
77057708 return Do_MultiXactIdWait (multi , status , infomask , true,
7706- rel , NULL , XLTW_None , remaining );
7709+ rel , NULL , XLTW_None , remaining , logLockFailure );
77077710}
77087711
77097712/*
0 commit comments