[Pgpool-general] Error in pgpool
Tatsuo Ishii
ishii at sraoss.co.jp
Fri Apr 3 13:18:32 UTC 2009
> Great, I assumed some sort of internal table of prepared statements wasn't getting cleared out. When you said it was expected behavior it confused me.
Sorry, I was wrong.
> I'm trying to patch against the pgpool-II-2.2 source, either I'm either too much of a cretin to apply it or pool_proto_modules.c has other changes?
The patch was against CVS HEAD. Could you try included new patch? It
was generated using diff -u (previous one was diff -c) and seems to be
nicely applied to 2.2-stable.
--
Tatsuo Ishii
SRA OSS, Inc. Japan
> xnagios:/usr/pgsql_src/pgpool-II-2.2# patch -p0 --verbose < DeAl22.patch
> Hmm... Looks like a new-style context diff to me...
> The text leading up to this was:
> --------------------------
> |Index: pool_proto_modules.c
> |===================================================================
> |RCS file: /cvsroot/pgpool/pgpool-II/pool_proto_modules.c,v
> |retrieving revision 1.6
> |diff -c -r1.6 pool_proto_modules.c
> |*** pool_proto_modules.c 22 Jan 2009 09:16:37 -0000 1.6
> |--- pool_proto_modules.c 3 Apr 2009 10:35:48 -0000
> --------------------------
> Patching file pool_proto_modules.c using Plan A...
> Hunk #1 FAILED at 141.
> Hunk #2 FAILED at 346.
> 2 out of 2 hunks FAILED -- saving rejects to file pool_proto_modules.c.rej
> done
>
>
> I was just going to edit it by hand but then I couldn't see what was going off in the patch. The best I could figure was that this if statement wrapping if (IsA(node, PrepareStmt)) was getting removed
>
> if (frontend)
> {
>
> ///////
>
> }
>
> And the following is now getting declared a bit further up at line 141
>
> POOL_MEMORY_POOL *old_context = NULL;
> Portal *portal;
>
> Is that correct?
>
> Thanks
> Glyn
>
> --- On Fri, 3/4/09, Tatsuo Ishii <ishii at sraoss.co.jp> wrote:
>
> > From: Tatsuo Ishii <ishii at sraoss.co.jp>
> > Subject: Re: [Pgpool-general] Error in pgpool
> > To: glynastill at yahoo.co.uk, nimesh.satam at gmail.com, pgpool-general at pgfoundry.org
> > Date: Friday, 3 April, 2009, 11:39 AM
> > I have looked into this and found that it was actually
> > caused by a bug
> > (this bug has been there since pgpool-II 2.1).
> >
> > When DISCARD ALL is sent, pgpool forgets all prepared
> > statement in its
> > internal table. Problem is, this is not done if the query
> > is in
> > reset_query_list. Included is a patch to solve the problem.
> > Please
> > try.
> >
> > By this fix, now reset_query_list should be able to contain
> > "DISCARD
> > ALL" without any errors in PostgreSQL.
> > --
> > Tatsuo Ishii
> > SRA OSS, Inc. Japan
> >
> > > > It would appear that switching reset_query_list
> > back from 'ABORT; DISCARD ALL' to 'ABORT; RESET
> > ALL; SET SESSION AUTHORIZATION DEFAULT' stops this
> > happening for us. I'm not 100% sure yet, but since I
> > changed this parameter and reloaded the configuration
> > I've not seen any more of these deallocate errors.
> > >
> > > That's expected behavior. DISCARD ALL conflicts
> > pgpool-II's automatic
> > > DEALLOCATE prepapred statements.
> > >
> > > > After I reloaded pgpool I gradually saw less of
> > the errors until they (appear to have) stopped, so I assume
> > the updated parameter is only read by the backend when a
> > client connects?
> > >
> > > Yes. Probably it should be documented somewhere
> > though.
> > >
> > > > I.e. I presume everyone connected before I
> > reloaded issued an 'ABORT; DISCARD ALL', and anyone
> > connecting afterwards would use 'ABORT; RESET ALL; SET
> > SESSION AUTHORIZATION DEFAULT' ?
> > >
> > > Right.
> > > --
> > > Tatsuo Ishii
> > > SRA OSS, Inc. Japan
> > >
>
>
>
-------------- next part --------------
Index: pool_proto_modules.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pool_proto_modules.c,v
retrieving revision 1.6
diff -u -r1.6 pool_proto_modules.c
--- pool_proto_modules.c 22 Jan 2009 09:16:37 -0000 1.6
+++ pool_proto_modules.c 3 Apr 2009 13:13:58 -0000
@@ -141,6 +141,9 @@
int deadlock_detected = 0;
int active_sql_transaction_error = 0;
+ POOL_MEMORY_POOL *old_context = NULL;
+ Portal *portal;
+
force_replication = 0;
if (query == NULL) /* need to read query from frontend? */
{
@@ -343,63 +346,66 @@
if (MASTER_SLAVE && TSTATE(backend) != 'E')
force_replication = 1;
- if (frontend)
+ /*
+ * Before we do followings only when frontend == NULL,
+ * which was wrong since if, for example, reset_query_list
+ * contains "DISCARD ALL", then it does not register
+ * pending function and it causes trying to DEALLOCATE non
+ * existing prepared statment(2009/4/3 Tatsuo).
+ */
+ if (IsA(node, PrepareStmt))
{
- POOL_MEMORY_POOL *old_context = NULL;
- Portal *portal;
+ pending_function = add_prepared_list;
+ portal = create_portal();
+ if (portal == NULL)
+ {
+ pool_error("SimpleQuery: create_portal() failed");
+ return POOL_END;
+ }
- if (IsA(node, PrepareStmt))
+ /* switch memory context */
+ old_context = pool_memory;
+ pool_memory = portal->prepare_ctxt;
+
+ portal->portal_name = NULL;
+ portal->stmt = copyObject(node);
+ portal->sql_string = NULL;
+ pending_prepared_portal = portal;
+ }
+ else if (IsA(node, DeallocateStmt))
+ {
+ pending_function = del_prepared_list;
+ portal = create_portal();
+ if (portal == NULL)
{
- pending_function = add_prepared_list;
- portal = create_portal();
- if (portal == NULL)
- {
- pool_error("SimpleQuery: create_portal() failed");
- return POOL_END;
- }
+ pool_error("SimpleQuery: create_portal() failed");
+ return POOL_END;
+ }
- /* switch memory context */
- old_context = pool_memory;
- pool_memory = portal->prepare_ctxt;
-
- portal->portal_name = NULL;
- portal->stmt = copyObject(node);
- portal->sql_string = NULL;
- pending_prepared_portal = portal;
- }
- else if (IsA(node, DeallocateStmt))
- {
- pending_function = del_prepared_list;
- portal = create_portal();
- if (portal == NULL)
- {
- pool_error("SimpleQuery: create_portal() failed");
- return POOL_END;
- }
+ /* switch memory context */
+ old_context = pool_memory;
+ pool_memory = portal->prepare_ctxt;
- /* switch memory context */
- old_context = pool_memory;
- pool_memory = portal->prepare_ctxt;
-
- portal->portal_name = NULL;
- portal->stmt = copyObject(node);
- portal->sql_string = NULL;
- pending_prepared_portal = portal;
- }
- else if (IsA(node, DiscardStmt))
+ portal->portal_name = NULL;
+ portal->stmt = copyObject(node);
+ portal->sql_string = NULL;
+ pending_prepared_portal = portal;
+ }
+ else if (IsA(node, DiscardStmt))
+ {
+ DiscardStmt *stmt = (DiscardStmt *)node;
+ if (stmt->target == DISCARD_ALL || stmt->target == DISCARD_PLANS)
{
- DiscardStmt *stmt = (DiscardStmt *)node;
- if (stmt->target == DISCARD_ALL || stmt->target == DISCARD_PLANS)
- {
- pending_function = delete_all_prepared_list;
- pending_prepared_portal = NULL;
- }
+ pending_function = delete_all_prepared_list;
+ pending_prepared_portal = NULL;
}
-
- /* switch old memory context */
- if (old_context)
- pool_memory = old_context;
}
+
+ /* switch old memory context */
+ if (old_context)
+ pool_memory = old_context;
+
+ /* end of wrong if (see 2009/4/3 comment above) */
}
if (frontend && IsA(node, ExecuteStmt))
More information about the Pgpool-general
mailing list