Re: [PATCHES] Snapshot management, final

2008-05-12 Thread Alvaro Herrera
Tom Lane wrote: Patch committed, with most of these fixed. On this item: > AtSubCommit_Snapshot can leave us with multiple RegdSnapshotElt's for > the same snap and s_level, which seems a bit bogus. I agree it is bogus. I punted though, and left the code as-is, with a comment stating the probl

Re: [PATCHES] Snapshot management, final

2008-05-11 Thread Tom Lane
Alvaro Herrera <[EMAIL PROTECTED]> writes: > Tom Lane wrote: >> Hmm ... but that "close" can't unregister the snapshot immediately, >> because you'd lose if the 2nd savepoint gets rolled back, no? Is the >> handling of this case even correct at the moment? > No, CLOSE is not rolled back: > ... >

Re: [PATCHES] Snapshot management, final

2008-05-11 Thread Alvaro Herrera
Tom Lane wrote: > Alvaro Herrera <[EMAIL PROTECTED]> writes: > > Tom Lane wrote: > >> Shouldn't UnregisterSnapshot insist that s_level be equal to current > >> xact nest level? > > > It can't check that; consider > > > begin; > > savepoint foo; > > declare cur cursor for select (1), (2), (3); > >

Re: [PATCHES] Snapshot management, final

2008-05-11 Thread Tom Lane
Alvaro Herrera <[EMAIL PROTECTED]> writes: > Tom Lane wrote: >> Shouldn't UnregisterSnapshot insist that s_level be equal to current >> xact nest level? > It can't check that; consider > begin; > savepoint foo; > declare cur cursor for select (1), (2), (3); > savepoint bar; > close cur; > commit;

Re: [PATCHES] Snapshot management, final

2008-05-11 Thread Alvaro Herrera
Tom Lane wrote: I'm revising the patch; this comment is flawed though: > Shouldn't UnregisterSnapshot insist that s_level be equal to current > xact nest level? It can't check that; consider begin; savepoint foo; declare cur cursor for select (1), (2), (3); savepoint bar; close cur; commit; Th

Re: [PATCHES] Snapshot management, final

2008-05-11 Thread Tom Lane
Alvaro Herrera <[EMAIL PROTECTED]> writes: > Tom Lane wrote: >> Also, I think that the whole snapshot-sharing mechanism is not working >> as intended except for the serializable case; otherwise sequences >> like >> x = RegisterSnapshot(GetTransactionSnapshot()); >> y = RegisterSnapshot(GetTransacti

Re: [PATCHES] Snapshot management, final

2008-05-10 Thread Alvaro Herrera
[Reposting with compressed patch] Okay, I think I've fixed most of the issues in the reviewed patch. Updated patch attached. The most interesting change is that I've done away with CopySnapshot as a public routine in favor of a new PushUpdatedSnapshot which does the copy-update-push sequence. Al

Re: [PATCHES] Snapshot management, final

2008-05-07 Thread Alvaro Herrera
Tom Lane wrote: > I looked over this patch and I think it still needs work. Thanks for the thorough review. I'll be working on these problems soon. -- Alvaro Herrerahttp://www.CommandPrompt.com/ PostgreSQL Replication, Consulting, Custom Development, 24x7 suppor

Re: [PATCHES] Snapshot management, final

2008-05-06 Thread Tom Lane
I wrote: > Also, I don't think the subtransaction management is correct at all. BTW, maybe it would make more sense to keep the reference count management inside ResourceOwners, instead of having a largely duplicative set of logic in snapmgr.c. regards, tom lane -- Sent

Re: [PATCHES] Snapshot management, final

2008-05-06 Thread Tom Lane
Alvaro Herrera <[EMAIL PROTECTED]> writes: > Simon Riggs wrote: >> On Tue, 2008-04-22 at 15:49 -0400, Alvaro Herrera wrote: >>> - Three CopySnapshot call sites remain outside snapmgr.c: DoCopy() on >>> copy.c, ExplainOnePlan() on explain.c and _SPI_execute_plan() on spi.c. >>> They are there becaus

Re: [PATCHES] Snapshot management, final

2008-04-23 Thread Alvaro Herrera
Alvaro Herrera wrote: > FWIW I noticed yesterday after going to bed that SnapshotContext serves > no useful purpose -- we can just remove it and store snaps in > TopTransactionContext. ... which is what the attached patch does. -- Alvaro Herrerahttp://www.Command

Re: [PATCHES] Snapshot management, final

2008-04-23 Thread Alvaro Herrera
Simon Riggs wrote: > Forgive me for being dense, but what is there to stop you using a > CopySnapshot in TopMemoryContext? If you did, there would be no way to > free it, nor would we notice it had been done, AFAICS. Not anything I'm > thinking about doing, though. Well, TopMemoryContext is no go

Re: [PATCHES] Snapshot management, final

2008-04-23 Thread Simon Riggs
On Wed, 2008-04-23 at 08:21 -0400, Alvaro Herrera wrote: > Simon Riggs wrote: > > On Tue, 2008-04-22 at 18:13 -0400, Alvaro Herrera wrote: > > > Simon Riggs wrote: > > > > > > > OK, so it can;t be copied to a longer lived memory context? > > > > > > If you need that ability, please explain. > >

Re: [PATCHES] Snapshot management, final

2008-04-23 Thread Alvaro Herrera
Tom Lane wrote: > The only reason we have memory contexts at all is to avoid the need to > track individual palloc'd objects. Since we're instituting exactly such > tracking for snapshots, there's no value in placing them in > general-purpose memory contexts. FWIW I noticed yesterday after going

Re: [PATCHES] Snapshot management, final

2008-04-23 Thread Alvaro Herrera
Simon Riggs wrote: > On Tue, 2008-04-22 at 18:13 -0400, Alvaro Herrera wrote: > > Simon Riggs wrote: > > > > > OK, so it can;t be copied to a longer lived memory context? > > > > If you need that ability, please explain. > > No, I wish to prevent that, not enable it. I see. Sure, we don't have

Re: [PATCHES] Snapshot management, final

2008-04-23 Thread Simon Riggs
On Tue, 2008-04-22 at 18:13 -0400, Alvaro Herrera wrote: > Simon Riggs wrote: > > > OK, so it can;t be copied to a longer lived memory context? > > CopySnapshot always copies snapshots to SnapshotContext, which is a > context that lives until transaction end. There's no mechanism for > copying a

Re: [PATCHES] Snapshot management, final

2008-04-22 Thread Alvaro Herrera
Tom Lane wrote: > Alvaro Herrera <[EMAIL PROTECTED]> writes: > > > CopySnapshot always copies snapshots to SnapshotContext, which is a > > context that lives until transaction end. There's no mechanism for > > copying a snapshot into another context, because I don't see the need. > > The only re

Re: [PATCHES] Snapshot management, final

2008-04-22 Thread Tom Lane
Alvaro Herrera <[EMAIL PROTECTED]> writes: > Simon Riggs wrote: >> OK, so it can;t be copied to a longer lived memory context? > CopySnapshot always copies snapshots to SnapshotContext, which is a > context that lives until transaction end. There's no mechanism for > copying a snapshot into anoth

Re: [PATCHES] Snapshot management, final

2008-04-22 Thread Alvaro Herrera
Simon Riggs wrote: > OK, so it can;t be copied to a longer lived memory context? CopySnapshot always copies snapshots to SnapshotContext, which is a context that lives until transaction end. There's no mechanism for copying a snapshot into another context, because I don't see the need. If you n

Re: [PATCHES] Snapshot management, final

2008-04-22 Thread Simon Riggs
On Tue, 2008-04-22 at 17:50 -0400, Alvaro Herrera wrote: > Simon Riggs wrote: > > On Tue, 2008-04-22 at 15:49 -0400, Alvaro Herrera wrote: > > > > > - Three CopySnapshot call sites remain outside snapmgr.c: DoCopy() on > > > copy.c, ExplainOnePlan() on explain.c and _SPI_execute_plan() on spi.c. >

Re: [PATCHES] Snapshot management, final

2008-04-22 Thread Alvaro Herrera
Simon Riggs wrote: > On Tue, 2008-04-22 at 15:49 -0400, Alvaro Herrera wrote: > > > - Three CopySnapshot call sites remain outside snapmgr.c: DoCopy() on > > copy.c, ExplainOnePlan() on explain.c and _SPI_execute_plan() on spi.c. > > They are there because they grab the current ActiveSnapshot, mod

Re: [PATCHES] Snapshot management, final

2008-04-22 Thread Simon Riggs
On Tue, 2008-04-22 at 15:49 -0400, Alvaro Herrera wrote: > - Three CopySnapshot call sites remain outside snapmgr.c: DoCopy() on > copy.c, ExplainOnePlan() on explain.c and _SPI_execute_plan() on spi.c. > They are there because they grab the current ActiveSnapshot, modify it, > and then use the re

[PATCHES] Snapshot management, final

2008-04-22 Thread Alvaro Herrera
Here is the patch for snapshot management I currently have. Below is a complete description of the changes in this patch. The most important change is on the use of CopySnapshot and the games with ActiveSnapshot. On the new code, whenever a piece of code needs a snapshot to persist, it is "regis