Re: [HACKERS] Use of ActiveSnapshot

2007-05-14 Thread Jan Wieck
On 5/14/2007 4:26 PM, Tom Lane wrote: Jan Wieck <[EMAIL PROTECTED]> writes: Which means that the 8.3 fix for the reproducible backend crash, I posted earlier, is to have SPI_cursor_open() save and restore ActiveSnapshot while calling RevalidateCachedPlan(). I'll cross check that this fixes thi

Re: [HACKERS] Use of ActiveSnapshot

2007-05-14 Thread Tom Lane
Jan Wieck <[EMAIL PROTECTED]> writes: > Which means that the 8.3 fix for the reproducible backend crash, I > posted earlier, is to have SPI_cursor_open() save and restore > ActiveSnapshot while calling RevalidateCachedPlan(). I'll cross check > that this fixes this symptom and commit later today

Re: [HACKERS] Use of ActiveSnapshot

2007-05-14 Thread Jan Wieck
On 5/14/2007 3:35 PM, Tom Lane wrote: Jan Wieck <[EMAIL PROTECTED]> writes: The only problem with that is that there are code paths that set ActiveSnapshot to palloc()'d memory that is released due to a MemoryContextDelete() without resetting ActiveSnapshot to NULL. Only at the very end of a

Re: [HACKERS] Use of ActiveSnapshot

2007-05-14 Thread Jan Wieck
On 5/14/2007 1:29 PM, Tom Lane wrote: Jan Wieck <[EMAIL PROTECTED]> writes: The comment for the call of pg_plan_queries in util/cache/plancache.c line 469 for example is fatally wrong. Not only should the snapshot be set by all callers at this point, but if the call actually does replan the qu

Re: [HACKERS] Use of ActiveSnapshot

2007-05-14 Thread Tom Lane
Jan Wieck <[EMAIL PROTECTED]> writes: > The only problem with that is that there are code paths that set > ActiveSnapshot to palloc()'d memory that is released due to a > MemoryContextDelete() without resetting ActiveSnapshot to NULL. Only at the very end of a transaction (where ActiveSnapshot *

Re: [HACKERS] Use of ActiveSnapshot

2007-05-14 Thread Tom Lane
Jan Wieck <[EMAIL PROTECTED]> writes: > The comment for the call of pg_plan_queries in util/cache/plancache.c > line 469 for example is fatally wrong. Not only should the snapshot be > set by all callers at this point, but if the call actually does replan > the queries, the existing ActiveSnapsh

Re: [HACKERS] Use of ActiveSnapshot

2007-05-14 Thread Jan Wieck
On 5/12/2007 4:53 PM, Jan Wieck wrote: Either calling pg_plan_queries() with needSnapshot=false or saving and restoring ActiveSnapshot will prevent the backend from dumping core in the mentioned example, but I am not entirely sure as to which one is the right solution. Attached is a self cont

[HACKERS] Use of ActiveSnapshot

2007-05-12 Thread Jan Wieck
The use of ActiveSnapshot throughout the code appears rather dangerous to me. It is a global pointer, assumed not to be set yet in some places, assumed to be saved and restored by the caller in others. The actual (context) memory it points to is sometimes explicitly freed, sometimes just left i