Re: Load distributed checkpoint - Mailing list pgsql-hackers

From Takayuki Tsunakawa
Subject Re: Load distributed checkpoint
Date
Msg-id 023301c71e98$eea3e850$19527c0a@OPERAO
Whole thread Raw
In response to Load distributed checkpoint  (ITAGAKI Takahiro <itagaki.takahiro@oss.ntt.co.jp>)
Responses Re: Load distributed checkpoint
List pgsql-hackers
Hello,

From: "Jim C. Nasby" <jim@nasby.net>Also, I have a dumb question... BgBufferSync uses buf_id1 to keep
track
> of what buffer the bgwriter_all scan is looking at, which means that
> it should remember where it was at the end of the last scan; yet
it's
> initialized to 0 every time BgBufferSync is called. Is there
someplace
> else that is remembering where the complete scan is leaving off when
> bgwriter_all_percent or bgwriter_all_maxpages is hit? Or does the
scan
> in fact just keep re-scanning the beginning of the buffers?

No. BgBufferSync() correctly keeps track of the position to restart
scanning at. bufid1 is not initialized to 0 every time BgBufferSync()
is called, because bufid1 is a static local variable. Please see the
following code. It prints:

a=0
a=1
a=2


#include <stdio.h>

void func(void)
{static int a = 0;
printf("a=%d\n", a);a++;
}

int main(void)
{func();func();func();
 return 0;
}





pgsql-hackers by date:

Previous
From: edwinoneel@acm.org
Date:
Subject: libpq.a in a universal binary
Next
From: "Simon Riggs"
Date:
Subject: TOAST table names