Re: BUG: Session getting disconnected while executing a function to create materialised views in PostgreSQL 9.6

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: "Saxena, Shivam" <shsaxena(at)teamdrg(dot)com>
Cc: "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>, DB Development DBAs <DBDevelopmentDBAs(at)teamdrg(dot)com>, "Lee, Ming" <milee(at)teamdrg(dot)com>
Subject: Re: BUG: Session getting disconnected while executing a function to create materialised views in PostgreSQL 9.6
Date: 2016-08-11 12:10:36
Message-ID: CAB7nPqRESWD8Ne7GNNEwt_0LmOBcCc4+4wLwPvaPQSmk2xxNZg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, Aug 11, 2016 at 6:30 PM, Saxena, Shivam <shsaxena(at)teamdrg(dot)com> wrote:
> While creating a 9.6 database environment we have come across a situation
> where the session is getting disconnected while running a function. Below
> are the DB details and function details.

Thanks for the report!

> Few other observations:
>
> The same code snippet runs fine in PostreSQL v9.5
> When we remove the clause WITH NO DATA, then the functions runs successfully

9.5.4 and other is impacted as well by this crash, down to 9.3, and
this is an oversight of 1651b9aa that made a matview query with WITH
NO DATA not run the parser/planner when executed. spi.c has a special
handling for CTAS, and this query runs into that, so any such query
executed through the SPI is going to crash on that:
(lldb) up 1
frame #4: 0x0000000105986dde
postgres`_SPI_execute_plan(plan=0x00007f9ff383c038,
paramLI=0x0000000000000000, snapshot=0x0000000000000000,
crosscheck_snapshot=0x0000000000000000, read_only='\0',
fire_triggers='\x01', tcount=0) + 1902 at spi.c:2228
2225 else
2226 {
2227 /* Must be an IF NOT EXISTS that
did nothing */
-> 2228 Assert(ctastmt->if_not_exists);
2229 _SPI_current->processed = 0;
2230 }
2231
(lldb) p *ctastmt
(CreateTableAsStmt) $1 = {
type = T_CreateTableAsStmt
query = 0x00007f9ff385e4d0
into = 0x00007f9ff3868ef0
relkind = OBJECT_MATVIEW
is_select_into = '\0'
if_not_exists = '\0'
}
I'll produce a patch in the worst case by tomorrow morning my time.
--
Michael

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Michael Paquier 2016-08-11 13:09:01 Re: BUG: Session getting disconnected while executing a function to create materialised views in PostgreSQL 9.6
Previous Message Saxena, Shivam 2016-08-11 09:30:06 BUG: Session getting disconnected while executing a function to create materialised views in PostgreSQL 9.6