ctx.transaction(ltx -> {If I correctly read the error message below (the fifth of 5 attempts for same payload) I must be reusing a pooled db connection for a second payload. If so, is this pbbouncer failing to close connection after transaction; jooq not signaling end of transaction, an artifact of intentional overload; other?
startProcess(ctx); //three inserts, two tables
writeSegments(ctx); //update single record by PK (repeated per client)
finishProcess(ctx); //three inserts, one table
});
2017-08-29T17:33:25-06:00 lonepeak9 [pool-1-thread-6] edu.utah.camplab.jx.AbstractPayload d3d3a62f-64cf-4ffe-b7f8-927943af5c3e: failed write attempt #5, SQL [insert into "process_input" ("id", "process_id", "input_type", "input_ref") values (?, ?, ?, ?)]; Batch entry 0 insert into "process_input" ("id", "process_id", "input_type", "input_ref") values ('11c0e3d1-59a5-469e-a77d-89dcc98f03e0'::uuid, '14271c8d-31ea-4cd7-bcba-62b2436a9c21'::uuid, 'pedfile', 'a3a1326a-cd40-4777-903f-546621028e9f') was aborted: ERROR: prepared statement "S_1" already exists Call getNextException to see other errors in the batch.
Yes, I've seen that bit, but wonder how that impacts the code
which is using/generating PreparedStatement calls?
Btw, of the 100 runs of the client only went through all 5
attempts and ultimately failed, though many clients successfully
resubmitted their payload. You can see below (if you strectch
your screen really wide) the first client (later runtime) failed
once then succeeded. (The emergency landing worked, dumping a
the json version of the data)
[u0138544@syslog camp]$ zcat yesterday/lonepeak9/messages.gz | grep 14a99861-fb7c-4c45-bed0-c12d0bd4ae15
2017-08-29T21:44:50-06:00 lonepeak9 [pool-1-thread-5] edu.utah.camplab.server.PayloadThread Saving Private Ryan: 14a99861-fb7c-4c45-bed0-c12d0bd4ae15
2017-08-29T21:44:50-06:00 lonepeak9 [pool-1-thread-5] edu.utah.camplab.jx.AbstractPayload sending 14a99861-fb7c-4c45-bed0-c12d0bd4ae15
2017-08-29T21:44:50-06:00 lonepeak9 [pool-1-thread-5] edu.utah.camplab.jx.AbstractPayload 14a99861-fb7c-4c45-bed0-c12d0bd4ae15: start transaction
2017-08-29T21:44:50-06:00 lonepeak9 [pool-1-thread-5] edu.utah.camplab.jx.AbstractPayload 14a99861-fb7c-4c45-bed0-c12d0bd4ae15: failed write attempt #1, SQL [insert into "process_input" ("id", "process_id", "input_type", "input_ref") values (?, ?, ?, ?)]; Batch entry 0 insert into "process_input" ("id", "process_id", "input_type", "input_ref") values ('e8a8f8cb-4b84-43b6-8c0d-8081a672deca'::uuid, 'c2c13b27-bc8a-4ece-aab2-036b93180b2e'::uuid, 'pedfile', 'a3a1326a-cd40-4777-903f-546621028e9f') was aborted: ERROR: prepared statement "S_1" already exists Call getNextException to see other errors in the batch.
2017-08-29T21:44:50-06:00 lonepeak9 [pool-1-thread-5] edu.utah.camplab.jx.AbstractPayload 14a99861-fb7c-4c45-bed0-c12d0bd4ae15: start transaction
2017-08-29T21:44:50-06:00 lonepeak9 [pool-1-thread-5] edu.utah.camplab.jx.AbstractPayload 14a99861-fb7c-4c45-bed0-c12d0bd4ae15: end transaction[u0138544@syslog camp]$ zcat yesterday/lonepeak9/messages.gz | grep d3d3a62f-64cf-4ffe-b7f8-927943af5c3e
2017-08-29T17:33:25-06:00 lonepeak9 [pool-1-thread-6] edu.utah.camplab.server.PayloadThread Saving Private Ryan: d3d3a62f-64cf-4ffe-b7f8-927943af5c3e
2017-08-29T17:33:25-06:00 lonepeak9 [pool-1-thread-6] edu.utah.camplab.jx.AbstractPayload sending d3d3a62f-64cf-4ffe-b7f8-927943af5c3e
2017-08-29T17:33:25-06:00 lonepeak9 [pool-1-thread-6] edu.utah.camplab.jx.AbstractPayload d3d3a62f-64cf-4ffe-b7f8-927943af5c3e: failed write attempt #1, SQL [insert into "process_input" ("id", "process_id", "input_type", "input_ref") values (?, ?, ?, ?)]; Batch entry 0 insert into "process_input" ("id", "process_id", "input_type", "input_ref") values ('05f9c2b7-b2a1-441b-aabe-686ed48e84c2'::uuid, '40cd010d-804d-4963-ad06-eca57b795f74'::uuid, 'pedfile', 'a3a1326a-cd40-4777-903f-546621028e9f') was aborted: ERROR: prepared statement "S_1" already exists Call getNextException to see other errors in the batch.
2017-08-29T17:33:25-06:00 lonepeak9 [pool-1-thread-6] edu.utah.camplab.jx.AbstractPayload d3d3a62f-64cf-4ffe-b7f8-927943af5c3e: failed write attempt #2, SQL [insert into "process_input" ("id", "process_id", "input_type", "input_ref") values (?, ?, ?, ?)]; Batch entry 0 insert into "process_input" ("id", "process_id", "input_type", "input_ref") values ('d29a39fd-e952-4c6b-a016-b6ca72f0a546'::uuid, '13083f28-a6c6-44a0-be14-e24f8add05f9'::uuid, 'pedfile', 'a3a1326a-cd40-4777-903f-546621028e9f') was aborted: ERROR: prepared statement "S_1" already exists Call getNextException to see other errors in the batch.
2017-08-29T17:33:25-06:00 lonepeak9 [pool-1-thread-6] edu.utah.camplab.jx.AbstractPayload d3d3a62f-64cf-4ffe-b7f8-927943af5c3e: failed write attempt #3, SQL [insert into "process_input" ("id", "process_id", "input_type", "input_ref") values (?, ?, ?, ?)]; Batch entry 0 insert into "process_input" ("id", "process_id", "input_type", "input_ref") values ('25831dcc-2cfe-4a54-a6e6-b5a4efec08da'::uuid, 'f150d753-822e-4aa2-8745-fc1ce6e99041'::uuid, 'pedfile', 'a3a1326a-cd40-4777-903f-546621028e9f') was aborted: ERROR: prepared statement "S_1" already exists Call getNextException to see other errors in the batch.
2017-08-29T17:33:25-06:00 lonepeak9 [pool-1-thread-6] edu.utah.camplab.jx.AbstractPayload d3d3a62f-64cf-4ffe-b7f8-927943af5c3e: failed write attempt #4, SQL [insert into "process_input" ("id", "process_id", "input_type", "input_ref") values (?, ?, ?, ?)]; Batch entry 0 insert into "process_input" ("id", "process_id", "input_type", "input_ref") values ('1ec5e560-35aa-4ea9-9c4b-22293a67b8bf'::uuid, '2d05a7a9-625e-4dfe-9e72-ec4671cdd67c'::uuid, 'pedfile', 'a3a1326a-cd40-4777-903f-546621028e9f') was aborted: ERROR: prepared statement "S_1" already exists Call getNextException to see other errors in the batch.
2017-08-29T17:33:25-06:00 lonepeak9 [pool-1-thread-6] edu.utah.camplab.jx.AbstractPayload d3d3a62f-64cf-4ffe-b7f8-927943af5c3e: failed write attempt #5, SQL [insert into "process_input" ("id", "process_id", "input_type", "input_ref") values (?, ?, ?, ?)]; Batch entry 0 insert into "process_input" ("id", "process_id", "input_type", "input_ref") values ('11c0e3d1-59a5-469e-a77d-89dcc98f03e0'::uuid, '14271c8d-31ea-4cd7-bcba-62b2436a9c21'::uuid, 'pedfile', 'a3a1326a-cd40-4777-903f-546621028e9f') was aborted: ERROR: prepared statement "S_1" already exists Call getNextException to see other errors in the batch.
2017-08-29T17:33:25-06:00 lonepeak9 [pool-1-thread-6] edu.utah.camplab.server.PayloadThread Write attempt failed for payload d3d3a62f-64cf-4ffe-b7f8-927943af5c3e. Trying emergency landing at /tmp/SGS.crashpad
2017-08-29T17:33:25-06:00 lonepeak9 [pool-1-thread-6] edu.utah.camplab.server.PayloadThread EMERGENCY LANDING: writing run d3d3a62f-64cf-4ffe-b7f8-927943af5c3e as json to /tmp/SGS.crashpad
I have augmented the connection url in the client code as thus:
Connection dbconn = DriverManager.getConnection(url+"?prepareThreshold=0", ...);
but I
still see the "already exists" message.
I tried putting that on the pgbouncer database definition line as:
tsgs = host=<dbhost> port=5432 dbname=tsgs prepareThreshold=0
but that isn't valid and disrupted any attempt to login (saying dbname tsgs does not exist)
However, on the postgres site, https://jdbc.postgresql.org/documentation/head/server-prepare.html, I don't see that zero turns it off (it defaults to 5). Can you confirm that zero is the kill switch here?
Thanks
I am NOT using PreparedStatment in my code.
Lukas,
I cross-posted as I was unsure as to where the solution may lay, and am still pretty much in the same boat.
I'm not in a hurry to over-ride the PreparedStatement usage. I will experiment as you've outlined but I'll have to weigh the injection risk. Mainly I'm curious as to how this re-use is occurring and if there's any corrective action in my general scheme. An explicit closing of the db connection perhaps? (The suggestion to augment the connection url with "?prepareThreshold=0" does not appear to change the outcome.)
--
You received this message because you are subscribed to the Google Groups "jOOQ User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I'll have to weigh the injection risk.
Mainly I'm curious as to how this re-use is occurring and if there's any corrective action in my general scheme. An explicit closing of the db connection perhaps?
Good news on the injection front. I ran with the Settings indicated and for the first time got 100% of my jobs saved properly. I have a second related client which has to store lists with 1k-10K entries. Any guess as to the performance difference here with v. without PreparedStatement in play? In this scenario, the jobs are much less frequent.
Thanks, as always
Note that the default setting is five, which means that the first four executions will actually use the bind parameters during prepare, the later ones not. That counter starts fresh for each PreparedStatement instance.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "jOOQ User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+unsubscribe@googlegroups.com.
Since I'm running two separate JVMs for each of my tasks, I will try using Static for the simple update case we've been discussing and Prepared for the task which does bulk inserts (jOOQ "batch").
I've split this discussion between the two group. Not sure if that was wise.
I still don't quite understand the collision (re-use of prep.
statement); it appears to be transient; I have instances of
several such failures then success from single client instance
(the client connects; fires transaction, but no specific
connection close; exit jvm. Is that last bit the root of the problem?
I'll try adding one. ..fumles around.. Using
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+...@googlegroups.com.
Sorry wrong keyboard
Using
while (i++ < 5) {
try(DSLContext c = DriverManager.getConnection(...)) {
write(ctx);
}
catch(SQLException e) {
logger.error("attempt #{} failed: {}", e.getMessage(), e);
}
Through 100 (gnu parallel) invocations of the java program I
get 98 attempt #1 failures, 96 #2s, 94 #3s, 2 #4s and a single
#5 and indeed I updated the target 99 times. Maybe I should just
do #6!
So it isn't the missing/(assumed) connection.close(). So I think I'll have to chase the other fork of this thread - the pgbouncer side. I'll up-date here if I learn anything - but I'm a very old dog so chances aren't good.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+...@googlegroups.com.
Ah, using postgresql-42.1.4.jar, db_url+"?prepareThreshold=0" and NOT setting jOOQ StatementType.STATIC_STATEMENT I get no messages about 'prepared statement already exists' and no failures in 100 clients over 16 cores.
I think that sums it up! Use current tools is the lesson.
Thanks to both tool providers (this is bcc'd to jooq list at pgbouncer list squawks on plain cc)
rjs
Hi Rob,
I can confirm this as I wrote the original patch to pgjdbc. :)
It may be the case that you need to use a more recent pgjdbc build as the patch got integrated within the last year or so (IIRC).
Regards,
Omar
On Thu, Sep 7, 2017 at 9:36 AM Rob Sargent <rob.s...@utah.edu> wrote:
Omar,
My last message may have not gone through because I was attempting to
cross-post to the jOOQ list. (I got a message about it being reviewed
for some forgotten reason.)
Can you confirm that zero is the kill switch for re-using prepared
statements on the server. And is it connection based? I have two
distinct modes of use and the other (not yet shown) makes heavy use of
jOOQ batch writing (sending lists of 1000s of items) which in turn uses
(quite sensibly) prepared statements. I have never seen this list-based
usage generate the error, but I don't go through pgbouncer connections
when doing so - a two-tiered scenario.
In the problematic case, I can turn off prepared statements from the
jOOQ interface and all seems well. I'm just trying to understand how
I'm hitting the 'already exists' error in the default world of
PreparedStatements under separate connections. Granted I am
intensionally flooding pgbouncer with requests: am I re-using pgbouncer
connections by repeated requests from same host/user thereby exposing a
client to re-using a prepared statement?
(I'll cross this back to the jOOQ list later)
Thanks