Re: Moving more work outside WALInsertLock - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: Moving more work outside WALInsertLock
Date
Msg-id 4EEA4520.1010604@enterprisedb.com
Whole thread Raw
In response to Re: Moving more work outside WALInsertLock  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Moving more work outside WALInsertLock  (Simon Riggs <simon@2ndQuadrant.com>)
List pgsql-hackers
On 15.12.2011 17:34, Tom Lane wrote:
> Heikki Linnakangas<heikki.linnakangas@enterprisedb.com>  writes:
>> I've been experimenting with different approaches to do that, but one
>> thing is common among all of them: you need to know the total amount of
>> WAL space needed for the record, including backup blocks, before you
>> take the lock. So, here's a patch to move things around in XLogInsert()
>> a bit, to accomplish that.
>
> This patch may or may not be useful, but this description of it is utter
> nonsense, because we already do compute that before taking the lock.

Nope. Without this patch, the total length including the backup blocks, 
write_len, is added up in the loop that creates the rdata entries for 
backup blocks. That is done while holding the lock (see code beginning 
with comment "Make additional rdata chain entries for the backup blocks").

Admittedly you could sum up the total length quite easily in the earlier 
loop, before we grab the lock, where we calculate the CRC of the backup 
blocks ("Now add the backup block headers and data into the CRC"). That 
would be a smaller patch.

> Please try again to explain what you're doing?

Ok: I'm moving the creation of rdata entries for backup blocks outside 
the critical section, so that it's done before grabbing the lock. I'm 
also moving the CRC calculation so that it's done after all the rdata 
entries have been created, including the ones for backup blocks. It's 
more readable to do it that way, as a separate step, instead of 
sprinkling the COMP_CRC macros in many places.

--   Heikki Linnakangas  EnterpriseDB   http://www.enterprisedb.com


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: FlexLocks
Next
From: Robert Haas
Date:
Subject: Re: CommitFest 2011-11 Update