From: | Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> |
---|---|
To: | Robert Haas <robertmhaas(at)gmail(dot)com> |
Cc: | Thom Brown <thom(at)linux(dot)com>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Noah Misch <noah(at)leadboat(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: assessing parallel-safety |
Date: | 2015-07-15 05:50:00 |
Message-ID: | CAA4eK1JMUtWjkxm85uVEhUJs+v+oJwCnaoKBKcTdwxdOhR5ymA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Fri, Jul 3, 2015 at 5:30 PM, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
>
>
> Attached, find the rebased patch which can be used to review/test latest
> version of parallel_seqscan patch which I am going to post in the parallel
> seq. scan thread soonish.
>
I went ahead and completed this patch with respect to adding new clause
in CREATE/ALTER FUNCTION which can allow users to define the
parallel property for User defined functions.
The new clause is defined as
Create Function ... PARALLEL {SAFE | RESTRICTED | UNSAFE}
Alter Function ... PARALLEL {SAFE | RESTRICTED | UNSAFE}
I have added PARALLEL as non-reserved keyword and store other
parameters as options which can be verified during CreateFunction.
Apart from this, added pg_dump support and updated the docs.
I have changed the parallel safety for some of the newly added
functions for pg_replication_origin* which will be defined as:
pg_replication_origin_create - unsafe, because it can start a transaction
pg_replication_origin_drop - unsafe, because it can start a transaction
pg_replication_origin_session_setup - unsafe, because it changes shared
memory state(ReplicationState) that is not shared among workers.
pg_replication_origin_session_reset - unsafe, because it changes shared
memory state(ReplicationState) that is not shared among workers.
pg_replication_origin_advance - unsafe, because it changes shared
memory state(ReplicationState) that is not shared among workers.
pg_replication_origin_progress - unsafe, because it can call XlogFlush
which can change shared memory state.
pg_replication_origin_session_progress - unsafe, because it can call
XlogFlush which can change shared memory state.
pg_replication_origin_xact_setup - Restricted,
because replorigin_sesssion_origin_lsn is not shared
pg_replication_origin_xact_reset - Restricted,
because replorigin_sesssion_origin_lsn is not shared
pg_replication_origin_session_is_setup - Restricted,
because replorigin_sesssion_origin is not shared
pg_show_replication_origin_status - Restricted, because
ReplicationState is not shared.
pg_replication_origin_oid - Safe
One issue which I think we should fix in this patch as pointed earlier
is, in some cases, Function containing Select stmt won't be able to
use parallel plan even though it is marked as parallel safe.
create or replace function parallel_func_select() returns integer
as $$
declare
ret_val int;
begin
Select c1 into ret_val from t1 where c1 = 1;
return ret_val;
end;
$$ language plpgsql Parallel Safe;
Above function won't be able to use parallel plan for Select statement
because of below code:
static int
exec_stmt_execsql(PLpgSQL_execstate *estate,
PLpgSQL_stmt_execsql
*stmt)
{
..
if (expr->plan == NULL)
{
..
exec_prepare_plan(estate, expr, 0);
}
..
}
As the cursorOptions passed in this function are always 0, planner
will treat it as unsafe function. Shouldn't we need to check parallelOk
to pass cursoroption in above function as is done in exec_run_select()
in patch?
With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com
Attachment | Content-Type | Size |
---|---|---|
assess-parallel-safety-v7.tar.gz | application/x-gzip | 92.2 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Paquier | 2015-07-15 06:28:58 | Re: ctidscan as an example of custom-scan (Re: [v9.5] Custom Plan API) |
Previous Message | Simon Riggs | 2015-07-15 05:38:04 | Re: TABLESAMPLE patch is really in pretty sad shape |