Re: [BUGS] Bug #613: Sequence values fall back to previously chec

2002-03-19 Thread Mikheev, Vadim
> Attached is a patch against current CVS that fixes both of the known > problems with sequences: failure to flush XLOG after a transaction Great! Thanks... and sorry for missing these cases year ago -:) Vadim ---(end of broadcast)--- TIP 1: subsc

Re: [BUGS] Bug #613: Sequence values fall back to previously chec

2002-03-19 Thread Vadim Mikheev
> But sequences should not be under transaction control. Can you > safely rollback a sequence? No! The only way to ensure that would ... > Placing a restriction on an application that says it must treat the values > returned from a sequence as if they might not be committed is absurd. Why? The

Re: [BUGS] Bug #613: Sequence values fall back to previously chec

2002-03-19 Thread Mikheev, Vadim
> > This isn't an issue for a SELECT nextval() standing on > > its own AFAIK the result will not be transmitted to the > > client until after the commit happens. But it would be > > an issue for a select executed inside a transaction > > block (begin/commit). > > The behavior of SELECT nextval()

Re: [BUGS] Bug #613: Sequence values fall back to previously chec

2002-03-15 Thread Tom Lane
"'Ben Grimm'" <[EMAIL PROTECTED]> writes: > On Fri, 15 Mar 2002, Tom Lane wrote: >> What's bug #3? I don't recall a third issue. > The problem I was seeing before is that when the postmaster was shutdown > properly, log_cnt in the sequence record was saved with whatever value it > had at the t

Re: [BUGS] Bug #613: Sequence values fall back to previously chec

2002-03-15 Thread 'Ben Grimm'
On Fri, 15 Mar 2002, Tom Lane wrote: > "'Ben Grimm'" <[EMAIL PROTECTED]> writes: > > When these bugs are fixed there is still the issue of bug #3 that I > > came across. The one that I work around by resetting log_cnt to 0 when a > > backend initializes a sequence. It's this third bug that ma

Re: [BUGS] Bug #613: Sequence values fall back to previously chec

2002-03-15 Thread Tom Lane
Attached is a patch against current CVS that fixes both of the known problems with sequences: failure to flush XLOG after a transaction that only does "SELECT nextval()", and failure to force a new WAL record to be written on the first nextval after a checkpoint. (The latter uses Vadim's idea of l

Re: [BUGS] Bug #613: Sequence values fall back to previously chec

2002-03-15 Thread Tom Lane
"'Ben Grimm'" <[EMAIL PROTECTED]> writes: > When these bugs are fixed there is still the issue of bug #3 that I > came across. The one that I work around by resetting log_cnt to 0 when a > backend initializes a sequence. It's this third bug that made the other > two so apparent. Fixing them

Re: [BUGS] Bug #613: Sequence values fall back to previously chec

2002-03-15 Thread 'Ben Grimm'
On Fri, 15 Mar 2002, Vadim Mikheev wrote: > > But sequences should not be under transaction control. Can you > > safely rollback a sequence? No! The only way to ensure that would > ... > > Placing a restriction on an application that says it must treat the values > > returned from a sequence a

Re: [BUGS] Bug #613: Sequence values fall back to previously chec

2002-03-14 Thread 'Ben Grimm'
On Thu, 14 Mar 2002, Mikheev, Vadim wrote: > And it's not. But behaviour of application *must* be > conditional on was transaction committed or not. > > What's the problem for application that need nextval() for > external (out-of-database) purposes to use sequence values > only after transactio

Re: [BUGS] Bug #613: Sequence values fall back to previously chec

2002-03-14 Thread Tom Lane
Ben Grimm <[EMAIL PROTECTED]> writes: > The behavior of SELECT nextval() should not be conditional on being in or > out of a transaction block. Nonsense. The behavior of INSERT or UPDATE is "conditional" in exactly the same way: you should not rely on the reported result until it's committed.

Re: [BUGS] Bug #613: Sequence values fall back to previously chec

2002-03-14 Thread Ben Grimm
On Thu, 14 Mar 2002, Tom Lane wrote: > > If you do a SELECT nextval() and then use the returned value externally > *without waiting for a commit acknowledgement*, then I think you are > risking trouble; there's no guarantee that the WAL record (if one is > needed) has hit disk yet, and so a crash

Re: [BUGS] Bug #613: Sequence values fall back to previously chec

2002-03-14 Thread Tom Lane
"Tom Pfau" <[EMAIL PROTECTED]> writes: > I'm concerned that the discussion here has been of the opinion that > since no records were written to the database using the value retrieved > from the sequence that no damage has been done. Um, you certainly didn't hear me saying that ;-) There are two

Re: [BUGS] Bug #613: Sequence values fall back to previously chec

2002-03-14 Thread bgrimm
On Thu, 14 Mar 2002, Tom Pfau wrote: > I don't fully understand the xlog files or WAL records but... > > Why isn't the writing of the WAL record based on the CACHE value of the > sequence? If a request to nextval() can't be satisfied by the cache, > the sequence on disk should be updated result

Re: [BUGS] Bug #613: Sequence values fall back to previously chec

2002-03-14 Thread Tom Pfau
I don't fully understand the xlog files or WAL records but... Why isn't the writing of the WAL record based on the CACHE value of the sequence? If a request to nextval() can't be satisfied by the cache, the sequence on disk should be updated resulting in a WAL record being written. If two sessi

Re: [BUGS] Bug #613: Sequence values fall back to previously chec

2002-03-14 Thread Mikheev, Vadim
> > It seems safe to do NOT write WAL record if sequence > > LSN > system RedoRecPtr because of checkpoint started after our > > check would finish only after writing to disk sequence buffer with > > proper last_value and log_cnt (nextval keeps lock on > > sequence buffer). > > Mmm ... maybe. I

Re: [BUGS] Bug #613: Sequence values fall back to previously chec

2002-03-14 Thread Mikheev, Vadim
> AFAICS the only way that we could make the one-WAL-record-every-32- > nextvals idea really work would be if CHECKPOINT could nullify the > logged-in-advance state of each sequence (so that the first nextval > after a checkpoint would always generate a fresh WAL record, but > subsequent ones woul

Re: [BUGS] Bug #613: Sequence values fall back to previously chec kpointed

2002-03-13 Thread Tom Lane
I said: > Mmm ... maybe. Is this safe if a checkpoint is currently in progress? > Seems like you could look at RedoRecPtr and decide you are okay, but you > really are not if checkpointer has already dumped sequence' disk > buffer and will later set RedoRecPtr to a value beyond the old LSN. Oh,

Re: [BUGS] Bug #613: Sequence values fall back to previously chec kpointed

2002-03-13 Thread Tom Lane
"Mikheev, Vadim" <[EMAIL PROTECTED]> writes: > It seems safe to do NOT write WAL record if sequence > LSN > system RedoRecPtr because of checkpoint started after our > check would finish only after writing to disk sequence buffer with > proper last_value and log_cnt (nextval keeps lock on sequence