Re: [HACKERS] MARKED_FOR_UPDATE XMAX_COMMITTED == XMAX_INVALID ?

2003-06-23 Thread Bruce Momjian

Your patch has been added to the PostgreSQL unapplied patches list at:

http://momjian.postgresql.org/cgi-bin/pgpatches

I will try to apply it within the next 48 hours.

---


Manfred Koizar wrote:
 On Wed, 11 Jun 2003 09:05:33 -0400, Tom Lane [EMAIL PROTECTED]
 wrote:
  If a transaction marks a tuple for update and later commits without
  actually having updated the tuple, [...] can we simply
  set the HEAP_XMAX_INVALID hint bit of the tuple?
 
 AFAICS this is a reasonable thing to do.
 
 Thanks for the confirmation.  Here's a patch which also contains some
 more noncritical changes to tqual.c:
  .  make code more readable by introducing local variables for xvac
  .  no longer two separate branches for aborted and crashed.
 The actions were the same in all cases.
 
 Servus
  Manfred

 diff -rcN ../base/src/backend/utils/time/tqual.c src/backend/utils/time/tqual.c
 *** ../base/src/backend/utils/time/tqual.cThu May  8 21:45:55 2003
 --- src/backend/utils/time/tqual.cThu Jun 12 12:10:31 2003
 ***
 *** 76,86 
   
   if (tuple-t_infomask  HEAP_MOVED_OFF)
   {
 ! if 
 (TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXvac(tuple)))
   return false;
 ! if (!TransactionIdIsInProgress(HeapTupleHeaderGetXvac(tuple)))
   {
 ! if 
 (TransactionIdDidCommit(HeapTupleHeaderGetXvac(tuple)))
   {
   tuple-t_infomask |= HEAP_XMIN_INVALID;
   return false;
 --- 76,87 
   
   if (tuple-t_infomask  HEAP_MOVED_OFF)
   {
 ! TransactionId xvac = HeapTupleHeaderGetXvac(tuple);
 ! if (TransactionIdIsCurrentTransactionId(xvac))
   return false;
 ! if (!TransactionIdIsInProgress(xvac))
   {
 ! if (TransactionIdDidCommit(xvac))
   {
   tuple-t_infomask |= HEAP_XMIN_INVALID;
   return false;
 ***
 *** 90,100 
   }
   else if (tuple-t_infomask  HEAP_MOVED_IN)
   {
 ! if 
 (!TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXvac(tuple)))
   {
 ! if 
 (TransactionIdIsInProgress(HeapTupleHeaderGetXvac(tuple)))
   return false;
 ! if 
 (TransactionIdDidCommit(HeapTupleHeaderGetXvac(tuple)))
   tuple-t_infomask |= HEAP_XMIN_COMMITTED;
   else
   {
 --- 91,102 
   }
   else if (tuple-t_infomask  HEAP_MOVED_IN)
   {
 ! TransactionId xvac = HeapTupleHeaderGetXvac(tuple);
 ! if (!TransactionIdIsCurrentTransactionId(xvac))
   {
 ! if (TransactionIdIsInProgress(xvac))
   return false;
 ! if (TransactionIdDidCommit(xvac))
   tuple-t_infomask |= HEAP_XMIN_COMMITTED;
   else
   {
 ***
 *** 152,162 
   }
   
   /* xmax transaction committed */
 - tuple-t_infomask |= HEAP_XMAX_COMMITTED;
   
   if (tuple-t_infomask  HEAP_MARKED_FOR_UPDATE)
   return true;
   
   return false;
   }
   
 --- 154,167 
   }
   
   /* xmax transaction committed */
   
   if (tuple-t_infomask  HEAP_MARKED_FOR_UPDATE)
 + {
 + tuple-t_infomask |= HEAP_XMAX_INVALID;
   return true;
 + }
   
 + tuple-t_infomask |= HEAP_XMAX_COMMITTED;
   return false;
   }
   
 ***
 *** 212,222 
   
   if (tuple-t_infomask  HEAP_MOVED_OFF)
   {
 ! if 
 (TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXvac(tuple)))
   return false;
 ! if (!TransactionIdIsInProgress(HeapTupleHeaderGetXvac(tuple)))
   {
 ! if 
 (TransactionIdDidCommit(HeapTupleHeaderGetXvac(tuple)))
   {
   tuple-t_infomask |= HEAP_XMIN_INVALID;
   return false;
 --- 217,228 
   
   if (tuple-t_infomask  HEAP_MOVED_OFF)
   {
 ! TransactionId xvac = HeapTupleHeaderGetXvac(tuple);
 ! if (TransactionIdIsCurrentTransactionId(xvac))
  

Re: [HACKERS] MARKED_FOR_UPDATE XMAX_COMMITTED == XMAX_INVALID ?

2003-06-12 Thread Manfred Koizar
On Wed, 11 Jun 2003 09:05:33 -0400, Tom Lane [EMAIL PROTECTED]
wrote:
 If a transaction marks a tuple for update and later commits without
 actually having updated the tuple, [...] can we simply
 set the HEAP_XMAX_INVALID hint bit of the tuple?

AFAICS this is a reasonable thing to do.

Thanks for the confirmation.  Here's a patch which also contains some
more noncritical changes to tqual.c:
 .  make code more readable by introducing local variables for xvac
 .  no longer two separate branches for aborted and crashed.
The actions were the same in all cases.

Servus
 Manfred
diff -rcN ../base/src/backend/utils/time/tqual.c src/backend/utils/time/tqual.c
*** ../base/src/backend/utils/time/tqual.c  Thu May  8 21:45:55 2003
--- src/backend/utils/time/tqual.c  Thu Jun 12 12:10:31 2003
***
*** 76,86 
  
if (tuple-t_infomask  HEAP_MOVED_OFF)
{
!   if 
(TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXvac(tuple)))
return false;
!   if (!TransactionIdIsInProgress(HeapTupleHeaderGetXvac(tuple)))
{
!   if 
(TransactionIdDidCommit(HeapTupleHeaderGetXvac(tuple)))
{
tuple-t_infomask |= HEAP_XMIN_INVALID;
return false;
--- 76,87 
  
if (tuple-t_infomask  HEAP_MOVED_OFF)
{
!   TransactionId xvac = HeapTupleHeaderGetXvac(tuple);
!   if (TransactionIdIsCurrentTransactionId(xvac))
return false;
!   if (!TransactionIdIsInProgress(xvac))
{
!   if (TransactionIdDidCommit(xvac))
{
tuple-t_infomask |= HEAP_XMIN_INVALID;
return false;
***
*** 90,100 
}
else if (tuple-t_infomask  HEAP_MOVED_IN)
{
!   if 
(!TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXvac(tuple)))
{
!   if 
(TransactionIdIsInProgress(HeapTupleHeaderGetXvac(tuple)))
return false;
!   if 
(TransactionIdDidCommit(HeapTupleHeaderGetXvac(tuple)))
tuple-t_infomask |= HEAP_XMIN_COMMITTED;
else
{
--- 91,102 
}
else if (tuple-t_infomask  HEAP_MOVED_IN)
{
!   TransactionId xvac = HeapTupleHeaderGetXvac(tuple);
!   if (!TransactionIdIsCurrentTransactionId(xvac))
{
!   if (TransactionIdIsInProgress(xvac))
return false;
!   if (TransactionIdDidCommit(xvac))
tuple-t_infomask |= HEAP_XMIN_COMMITTED;
else
{
***
*** 152,162 
}
  
/* xmax transaction committed */
-   tuple-t_infomask |= HEAP_XMAX_COMMITTED;
  
if (tuple-t_infomask  HEAP_MARKED_FOR_UPDATE)
return true;
  
return false;
  }
  
--- 154,167 
}
  
/* xmax transaction committed */
  
if (tuple-t_infomask  HEAP_MARKED_FOR_UPDATE)
+   {
+   tuple-t_infomask |= HEAP_XMAX_INVALID;
return true;
+   }
  
+   tuple-t_infomask |= HEAP_XMAX_COMMITTED;
return false;
  }
  
***
*** 212,222 
  
if (tuple-t_infomask  HEAP_MOVED_OFF)
{
!   if 
(TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXvac(tuple)))
return false;
!   if (!TransactionIdIsInProgress(HeapTupleHeaderGetXvac(tuple)))
{
!   if 
(TransactionIdDidCommit(HeapTupleHeaderGetXvac(tuple)))
{
tuple-t_infomask |= HEAP_XMIN_INVALID;
return false;
--- 217,228 
  
if (tuple-t_infomask  HEAP_MOVED_OFF)
{
!   TransactionId xvac = HeapTupleHeaderGetXvac(tuple);
!   if (TransactionIdIsCurrentTransactionId(xvac))
return false;
!   if (!TransactionIdIsInProgress(xvac))
{
!   if (TransactionIdDidCommit(xvac))
{

[HACKERS] MARKED_FOR_UPDATE XMAX_COMMITTED == XMAX_INVALID ?

2003-06-11 Thread Manfred Koizar
If a transaction marks a tuple for update and later commits without
actually having updated the tuple, do we still need the information
that the tuple has once been reserved for an update or can we simply
set the HEAP_XMAX_INVALID hint bit of the tuple?

In other words, is this snippet from a patch I'm working on a valid
modification to HeapTupleSatisfiesVacuum in tqual.c?

{
if (TransactionIdIsInProgress(HeapTupleHeaderGetXmax(tuple)))
return HEAPTUPLE_LIVE;
-   if (TransactionIdDidCommit(HeapTupleHeaderGetXmax(tuple)))
-   tuple-t_infomask |= HEAP_XMAX_COMMITTED;
-   else
-/* it's either aborted or crashed */
-   tuple-t_infomask |= HEAP_XMAX_INVALID;
+   /*
+* We don't really care whether xmax did commit, abort or
+* crash. We know that xmax did mark the tuple for update,
+* but it did not and will never actually update it.
+*/
+   tuple-t_infomask |= HEAP_XMAX_INVALID;
}
return HEAPTUPLE_LIVE;

There are a few more places in tqual.c which could be simplified like
that.

Servus
 Manfred

---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html


Re: [HACKERS] MARKED_FOR_UPDATE XMAX_COMMITTED == XMAX_INVALID ?

2003-06-11 Thread Tom Lane
Manfred Koizar [EMAIL PROTECTED] writes:
 If a transaction marks a tuple for update and later commits without
 actually having updated the tuple, do we still need the information
 that the tuple has once been reserved for an update or can we simply
 set the HEAP_XMAX_INVALID hint bit of the tuple?

AFAICS this is a reasonable thing to do.

Eventually we might also be able to remove the bits of logic that check
for MARKED_FOR_UPDATE in a committed tuple, but that would not be
backwards-compatible so I'd vote against doing it immediately.

regards, tom lane

---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]