Re: Re: [COMMITTERS] pgsql: Reduce WAL activity for page splits: > Currently, an index split

Поиск
Список
Период
Сортировка
От Heikki Linnakangas
Тема Re: Re: [COMMITTERS] pgsql: Reduce WAL activity for page splits: > Currently, an index split
Дата
Msg-id 45CAF13F.6020008@enterprisedb.com
обсуждение исходный текст
Ответ на Re: [COMMITTERS] pgsql: Reduce WAL activity for page splits: > Currently, an index split  (Stefan Kaltenbrunner <stefan@kaltenbrunner.cc>)
Ответы Re: Re: [COMMITTERS] pgsql: Reduce WAL activity for page splits: > Currently, an index split  (Stefan Kaltenbrunner <stefan@kaltenbrunner.cc>)
Re: Re: [COMMITTERS] pgsql: Reduce WAL activity for page splits: > Currently, an index split  (Alvaro Herrera <alvherre@commandprompt.com>)
Список pgsql-hackers
Stefan Kaltenbrunner wrote:
> Bruce Momjian wrote:
>> Log Message:
>> -----------
>> Reduce WAL activity for page splits:
>>
>>> Currently, an index split writes all the data on the split page to
>>> WAL. That's a lot of WAL traffic. The tuples that are copied to the
>>> right page need to be WAL logged, but the tuples that stay on the
>>> original page don't.
>
>
> this patch killed both of my OpenBSD buildfarm members

lopaque was referenced after pfreeing the temp page it pointed to. Also
later in the function the LSN of the left page was set, but again using
a pointer to the pfreed temp copy instead of the real shared memory buffer.

Here's a fix.

--
   Heikki Linnakangas
   EnterpriseDB   http://www.enterprisedb.com
Index: src/backend/access/nbtree/nbtinsert.c
===================================================================
RCS file: /home/hlinnaka/pgcvsrepository/pgsql/src/backend/access/nbtree/nbtinsert.c,v
retrieving revision 1.150
diff -c -r1.150 nbtinsert.c
*** src/backend/access/nbtree/nbtinsert.c    8 Feb 2007 05:05:53 -0000    1.150
--- src/backend/access/nbtree/nbtinsert.c    8 Feb 2007 09:36:05 -0000
***************
*** 953,959 ****
          xlrec.rightsib = BufferGetBlockNumber(rbuf);
          xlrec.firstright = firstright;
          xlrec.rnext = ropaque->btpo_next;
!         xlrec.level = lopaque->btpo.level;

          rdata[0].data = (char *) &xlrec;
          rdata[0].len = SizeOfBtreeSplit;
--- 953,959 ----
          xlrec.rightsib = BufferGetBlockNumber(rbuf);
          xlrec.firstright = firstright;
          xlrec.rnext = ropaque->btpo_next;
!         xlrec.level = ropaque->btpo.level;

          rdata[0].data = (char *) &xlrec;
          rdata[0].len = SizeOfBtreeSplit;
***************
*** 962,968 ****
          lastrdata = &rdata[0];

          /* Log downlink on non-leaf pages. */
!         if (lopaque->btpo.level > 0)
          {
              lastrdata->next = lastrdata + 1;
              lastrdata++;
--- 962,968 ----
          lastrdata = &rdata[0];

          /* Log downlink on non-leaf pages. */
!         if (ropaque->btpo.level > 0)
          {
              lastrdata->next = lastrdata + 1;
              lastrdata++;
***************
*** 1040,1047 ****

          recptr = XLogInsert(RM_BTREE_ID, xlinfo, rdata);

!         PageSetLSN(leftpage, recptr);
!         PageSetTLI(leftpage, ThisTimeLineID);
          PageSetLSN(rightpage, recptr);
          PageSetTLI(rightpage, ThisTimeLineID);
          if (!P_RIGHTMOST(ropaque))
--- 1040,1047 ----

          recptr = XLogInsert(RM_BTREE_ID, xlinfo, rdata);

!         PageSetLSN(origpage, recptr);
!         PageSetTLI(origpage, ThisTimeLineID);
          PageSetLSN(rightpage, recptr);
          PageSetTLI(rightpage, ThisTimeLineID);
          if (!P_RIGHTMOST(ropaque))

В списке pgsql-hackers по дате отправления:

Предыдущее
От: "Zeugswetter Andreas ADI SD"
Дата:
Сообщение: Re: Proposal: Commit timestamp
Следующее
От: Stefan Kaltenbrunner
Дата:
Сообщение: Re: Re: [COMMITTERS] pgsql: Reduce WAL activity for page splits: > Currently, an index split