View Issue Details

IDProjectCategoryView StatusLast Update
0000168Pgpool-IIBugpublic2016-03-03 15:03
Reportertest11 Assigned Tot-ishii  
PriorityurgentSeveritymajorReproducibilityalways
Status resolvedResolutionopen 
Summary0000168: 3.5.0 issues with php-pdo
DescriptionIf you run a syntactically erroneous query with a php-pdo client, pgpool-II 3.5.0 will not forward the error message to the frontend, and the client will wait for it infinitely.
This bug appeared in version 3.5, in stream replication mode.

It's something correlated with this block of code:
        else if (STREAM)
        {
                /* XXX fix me:even with streaming replication mode, couldn't we have a deadlock */
                pool_set_query_in_progress();
                pool_extended_send_and_wait(query_context, "P", len, contents, 1, MASTER_NODE_ID, true);
                pool_extended_send_and_wait(query_context, "P", len, contents, -1, MASTER_NODE_ID, true);
                pool_add_sent_message(session_context->uncompleted_message);
                pool_unset_query_in_progress();
        }


if you comment out the line pool_unset_query_in_progress();, everything works as expected, but i'm not sure about the drawbacks of this change.
Steps To Reproducephp -r '$p = new PDO("pgsql:host=127.0.0.1","postgres","your_pw");try{$s=$p->prepare("blah");$s->execute();}catch(Exception $e){var_dump($e);}'
Additional Information2016-03-02 19:06:22: pid 146308: DETAIL: received kind 'P'(50) from frontend
2016-03-02 19:06:22: pid 146308: DEBUG: session context: clearing doing extended query messaging. DONE
2016-03-02 19:06:22: pid 146308: DEBUG: session context: setting doing extended query messaging. DONE
2016-03-02 19:06:22: pid 146308: DEBUG: Parse: statement name <pdo_stmt_00000001>
2016-03-02 19:06:22: pid 146308: LOG: Unable to parse the query: "insert blah" from client 10.0.0.30(51264)
2016-03-02 19:06:22: pid 146308: DEBUG: session context: setting query in progress. DONE
2016-03-02 19:06:22: pid 146308: DEBUG: decide where to send the queries
2016-03-02 19:06:22: pid 146308: DETAIL: destination = 0 for query= "insert blah"
2016-03-02 19:06:22: pid 146308: DEBUG: session context: setting query in progress. DONE
2016-03-02 19:06:22: pid 146308: DEBUG: pool_write: to backend: kind:P
2016-03-02 19:06:22: pid 146308: DEBUG: called by pool_add_sent_message: sent message: address: 1d6e7e0 kind: P name: =pdo_stmt_00000001=
2016-03-02 19:06:22: pid 146308: DEBUG: session context: unsetting query in progress. DONE
2016-03-02 19:06:22: pid 146308: DEBUG: processing frontend response
2016-03-02 19:06:22: pid 146308: DETAIL: received kind 'S'(53) from frontend
2016-03-02 19:06:22: pid 146308: DEBUG: session context: clearing doing extended query messaging. DONE
2016-03-02 19:06:22: pid 146308: DEBUG: session context: setting doing extended query messaging. DONE
2016-03-02 19:06:22: pid 146308: DEBUG: session context: setting query in progress. DONE
2016-03-02 19:06:22: pid 146308: DEBUG: pool_write: to backend: kind:S
2016-03-02 19:06:22: pid 146308: DEBUG: pool_read: read 86 bytes from backend 0
2016-03-02 19:06:22: pid 146308: DEBUG: reading backend data packet kind
2016-03-02 19:06:22: pid 146308: DETAIL: master node id: 0
2016-03-02 19:06:22: pid 146308: DEBUG: reading backend data packet kind
2016-03-02 19:06:22: pid 146308: DETAIL: backend:0 of 3 kind = 'E'
2016-03-02 19:06:22: pid 146308: DEBUG: read_kind_from_backend max_count:1.000000 num_executed_nodes:1
2016-03-02 19:06:22: pid 146308: DEBUG: processing backend response
2016-03-02 19:06:22: pid 146308: DETAIL: received kind 'E'(45) from backend
2016-03-02 19:06:22: pid 146308: DEBUG: SimpleForwardToFrontend: packet:E length:81
2016-03-02 19:06:22: pid 146308: DEBUG: session context: clearing transaction isolation. DONE
2016-03-02 19:06:22: pid 146308: DEBUG: session context: setting ignore till sync. DONE
2016-03-02 19:06:22: pid 146308: DEBUG: session context: unsetting query in progress. DONE
2016-03-02 19:06:22: pid 146308: DEBUG: pool_read: read 6 bytes from backend 0
2016-03-02 19:06:22: pid 146308: DEBUG: detect error: kind: Z
2016-03-02 19:06:22: pid 146308: DEBUG: detect error: kind: Z
2016-03-02 19:06:22: pid 146308: DEBUG: detect error: kind: Z
TagsNo tags attached.

Activities

t-ishii

2016-03-03 07:39

developer   ~0000664

Sounds like a similar problem in:
http://www.pgpool.net/mantisbt/view.php?id=167

Can you please try the fix attached to above (bug167.diff)?

test11

2016-03-03 13:49

reporter   ~0000665

Last edited: 2016-03-03 13:51

In my case, the load_balancing mode on/off, is irrelevant (the query cannot be parsed, why should it be load balanced?).
Anyway, i've tried the bug167.diff, and the behaviour (and the debug output) is the same in all of scenarios: with or without path, with or without load balancing.

It's really easy to reproduce, just run that cli command against pgpool 3.5 or against 3.4/raw postgres
php -r '$p = new PDO("pgsql:host=127.0.0.1 port=5432","postgres","pass");$s=$p->prepare("blah");$s->execute();var_dump($s->errorInfo());'

the result should be (3.4/raw postgres):
array(3) {
  [0]=>
  string(5) "42601"
  [1]=>
  int(7)
  [2]=>
  string(61) "ERROR: syntax error at or near "blah"
LINE 1: blah
        ^"
}

but in 3.5 the client will hang up waiting for pgpool response

t-ishii

2016-03-03 14:19

developer  

pdo.diff (10,879 bytes)   
pdo.diff (10,879 bytes)   

t-ishii

2016-03-03 14:22

developer   ~0000666

I found different cause of your problem.
Can you please try attached patch (pdo.diff) against V3_5_STABLE?
You need the latest V3_5_STABLE head source.
If you don't have that, you can try the patch:
http://git.postgresql.org/gitweb/?p=pgpool2.git;a=commit;h=d8a8eb83e735734895a4def9a96a7ff83dd56517

test11

2016-03-03 14:47

reporter   ~0000667

Yes, it works. Thank you!

t-ishii

2016-03-03 15:02

developer   ~0000668

Glad to hear that. Thanks for the feedback!

Issue History

Date Modified Username Field Change
2016-03-03 03:11 test11 New Issue
2016-03-03 07:35 t-ishii Assigned To => t-ishii
2016-03-03 07:35 t-ishii Status new => feedback
2016-03-03 07:39 t-ishii Note Added: 0000664
2016-03-03 13:49 test11 Note Added: 0000665
2016-03-03 13:49 test11 Status feedback => assigned
2016-03-03 13:51 test11 Note Edited: 0000665
2016-03-03 14:19 t-ishii File Added: pdo.diff
2016-03-03 14:22 t-ishii Note Added: 0000666
2016-03-03 14:42 t-ishii Status assigned => feedback
2016-03-03 14:47 test11 Note Added: 0000667
2016-03-03 14:47 test11 Status feedback => assigned
2016-03-03 15:02 t-ishii Note Added: 0000668
2016-03-03 15:03 t-ishii Status assigned => resolved