Re: Bug #613: Sequence values fall back to previously checkpointed
| От | Ben Grimm |
|---|---|
| Тема | Re: Bug #613: Sequence values fall back to previously checkpointed |
| Дата | |
| Msg-id | 20020313102811.A32611@zaeon.com обсуждение исходный текст |
| Ответ на | Re: Bug #613: Sequence values fall back to previously checkpointed (Tom Lane <tgl@sss.pgh.pa.us>) |
| Ответы |
Re: Bug #613: Sequence values fall back to previously checkpointed
|
| Список | pgsql-bugs |
On Wed, 13 Mar 2002, Tom Lane wrote:
>
> Accordingly, I'm thinking that we must remove the SEQ_LOG_VALS
> functionality and force one-WAL-record-per-nextval operation.
>
> Vadim, do you see another way? This was a cool idea and I hate
> to throw it away...
>
It seems like you just need to ensure that when the sequence is loaded
from disk that log_cnt gets updated and written back to disk before the
sequence is used. I'm not sure of the impact, but I can't reproduce the
bugs after making these changes. I just added a flag to the SeqTableData
struct to say whether its been logged yet - this seems like overkill..
but it works for me :-) (at least in the scenarios I've tried)
-- Ben
*** src/backend/commands/sequence.c Wed Mar 13 11:14:42 2002
--- src/backend/commands/sequence.c.orig Tue Mar 12 18:58:55 2002
***************
*** 62,68 ****
int64 cached;
int64 last;
int64 increment;
- bool islogged;
struct SeqTableData *next;
} SeqTableData;
--- 62,67 ----
***************
*** 315,321 ****
PG_RETURN_INT64(elm->last);
}
! seq = read_info("nextval", elm, &buf); /* lock page' buffer and read tuple */
last = next = result = seq->last_value;
incby = seq->increment_by;
--- 314,321 ----
PG_RETURN_INT64(elm->last);
}
! seq = read_info("nextval", elm, &buf); /* lock page' buffer and
! * read tuple */
last = next = result = seq->last_value;
incby = seq->increment_by;
***************
*** 331,337 ****
log--;
}
! if (log < fetch || !elm->islogged)
{
fetch = log = fetch - log + SEQ_LOG_VALS;
logit = true;
--- 331,337 ----
log--;
}
! if (log < fetch)
{
fetch = log = fetch - log + SEQ_LOG_VALS;
logit = true;
***************
*** 405,411 ****
rdata[0].next = &(rdata[1]);
seq->last_value = next;
! elm->islogged = seq->is_called = true;
seq->log_cnt = 0;
rdata[1].buffer = InvalidBuffer;
rdata[1].data = (char *) page + ((PageHeader) page)->pd_upper;
--- 405,411 ----
rdata[0].next = &(rdata[1]);
seq->last_value = next;
! seq->is_called = true;
seq->log_cnt = 0;
rdata[1].buffer = InvalidBuffer;
rdata[1].data = (char *) page + ((PageHeader) page)->pd_upper;
***************
*** 417,424 ****
PageSetLSN(page, recptr);
PageSetSUI(page, ThisStartUpID);
! XLogFlush(recptr);
!
if (fetch) /* not all numbers were fetched */
log -= fetch;
}
--- 417,423 ----
PageSetLSN(page, recptr);
PageSetSUI(page, ThisStartUpID);
!
if (fetch) /* not all numbers were fetched */
log -= fetch;
}
***************
*** 729,735 ****
prev->next = elm;
}
- elm->islogged = false;
return elm;
}
--- 728,733 ----
В списке pgsql-bugs по дате отправления: