pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedMyBatis Batch Update Leads to PSQLException "Too many update results were returned"
6+ messages / 2 participants
[nested] [flat]
* MyBatis Batch Update Leads to PSQLException "Too many update results were returned"
@ 2018-02-27 21:19 Chris Dole <chris.dole@sas.com>
0 siblings, 2 replies; 6+ messages in thread
From: Chris Dole @ 2018-02-27 21:19 UTC (permalink / raw)
To: pgsql-jdbc
I have a fairly simple implementation of a batch update via the MyBatis
functionality.
Postgres version (via RDS on Amazon Web Services): 9.6.6
JDBC driver version: 9.4
The error manifests as follows:
DataIntegrityViolationException
Root cause: BatchUpdateException
getNextException: PSQLException - Too many update results were returned.
Has anyone else run into this? I have searched far and wide for an
explanation (including here) but have not found an answer yet.
I assume this error is coming up from the JDBC driver?
The curious thing is that the update seems to work (as in database
side-effects) but it still throws an exception afterward.
Here is a fragment of the MyBatis mapper XML file for the update. The
failure can happen for as few as two or three updates, and it can succeed
with hundreds.
<update id="update" parameterType="java.util.List">
<foreach collection="list" item="item" index="index" separator=";">
UPDATE public.vid_event_timing SET mark_delete = 1 WHERE
visitor_id=#{item.vid} AND timed_node_id=#{item.timedNodeId} AND
conditional_node_id= #{item.conditionalNodeId}
</foreach>
</update>
The MyBatis/Spring configuration includes this session factory bean, set to
ExecutorType.BATCH by default.
@Bean
public SqlSessionTemplate getSqlSessionTemplate()
{
SqlSessionFactory sessionFactory = null;
try
{
sessionFactory =
getMktPersistDesignSqlSessionFactoryBean().getObject();
sessionFactory.getConfiguration().setDefaultExecutorType(ExecutorType.BATCH);
}
catch (Exception e)
{
String message = PersistLogUtil.error(logger, "Failed to create
SqlSessionTemplate");
throw new RuntimeException(message, e);
}
SqlSessionTemplate template = new
SqlSessionTemplate(sessionFactory);
return template;
}
Thanks for any help.
--
Sent from: http://www.postgresql-archive.org/PostgreSQL-jdbc-f2168246.html
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: MyBatis Batch Update Leads to PSQLException "Too many update results were returned"
@ 2018-03-02 21:05 Dave Cramer <pg@fastcrypt.com>
parent: Chris Dole <chris.dole@sas.com>
1 sibling, 0 replies; 6+ messages in thread
From: Dave Cramer @ 2018-03-02 21:05 UTC (permalink / raw)
To: Chris Dole <chris.dole@sas.com>; +Cc: pgsql-jdbc
Please upgrade to a more recent version of the driver and retest., we would
not backpatch. 9.4 drivers
Dave Cramer
davec@postgresintl.com
www.postgresintl.com
On 27 February 2018 at 16:19, Chris Dole <chris.dole@sas.com> wrote:
> I have a fairly simple implementation of a batch update via the MyBatis
> functionality.
>
> Postgres version (via RDS on Amazon Web Services): 9.6.6
> JDBC driver version: 9.4
>
> The error manifests as follows:
>
> DataIntegrityViolationException
> Root cause: BatchUpdateException
> getNextException: PSQLException - Too many update results were returned.
>
> Has anyone else run into this? I have searched far and wide for an
> explanation (including here) but have not found an answer yet.
>
> I assume this error is coming up from the JDBC driver?
>
> The curious thing is that the update seems to work (as in database
> side-effects) but it still throws an exception afterward.
>
> Here is a fragment of the MyBatis mapper XML file for the update. The
> failure can happen for as few as two or three updates, and it can succeed
> with hundreds.
>
> <update id="update" parameterType="java.util.List">
> <foreach collection="list" item="item" index="index" separator=";">
> UPDATE public.vid_event_timing SET mark_delete = 1 WHERE
> visitor_id=#{item.vid} AND timed_node_id=#{item.timedNodeId}
> AND
> conditional_node_id= #{item.conditionalNodeId}
> </foreach>
> </update>
>
> The MyBatis/Spring configuration includes this session factory bean, set to
> ExecutorType.BATCH by default.
>
> @Bean
> public SqlSessionTemplate getSqlSessionTemplate()
> {
> SqlSessionFactory sessionFactory = null;
> try
> {
> sessionFactory =
> getMktPersistDesignSqlSessionFactoryBean().getObject();
>
> sessionFactory.getConfiguration().setDefaultExecutorType(
> ExecutorType.BATCH);
> }
> catch (Exception e)
> {
> String message = PersistLogUtil.error(logger, "Failed to create
> SqlSessionTemplate");
> throw new RuntimeException(message, e);
> }
> SqlSessionTemplate template = new
> SqlSessionTemplate(sessionFactory);
> return template;
> }
>
> Thanks for any help.
>
>
>
>
> --
> Sent from: http://www.postgresql-archive.org/PostgreSQL-jdbc-f2168246.html
>
>
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: MyBatis Batch Update Leads to PSQLException "Too many update results were returned"
@ 2018-03-02 21:13 Chris Dole <chris.dole@sas.com>
parent: Chris Dole <chris.dole@sas.com>
1 sibling, 1 reply; 6+ messages in thread
From: Chris Dole @ 2018-03-02 21:13 UTC (permalink / raw)
To: pgsql-jdbc
Thanks Dave. I actually did just that, using:
https://jdbc.postgresql.org/download/postgresql-42.2.1.jre7.jar
The result was basically the same, just a different nesting of the
exceptions:
DataIntegrityViolationException
root cause: PSQLException: ... too many updates ...
I was hoping an updated driver would help, but it appears to have the same
issue.
Regards,
Chris
--
Sent from: http://www.postgresql-archive.org/PostgreSQL-jdbc-f2168246.html
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: MyBatis Batch Update Leads to PSQLException "Too many update results were returned"
@ 2018-03-04 13:48 Dave Cramer <pg@fastcrypt.com>
parent: Chris Dole <chris.dole@sas.com>
0 siblings, 1 reply; 6+ messages in thread
From: Dave Cramer @ 2018-03-04 13:48 UTC (permalink / raw)
To: Chris Dole <chris.dole@sas.com>; +Cc: pgsql-jdbc
Chris,
Well given that this is deep inside the bowels of Batis, it's not something
we can easily debug.
If you can provide us with a self contained test case that exhibits the
problem then we can help figure it out.
Thanks
Dave Cramer
davec@postgresintl.com
www.postgresintl.com
On 2 March 2018 at 16:13, Chris Dole <chris.dole@sas.com> wrote:
> Thanks Dave. I actually did just that, using:
>
> https://jdbc.postgresql.org/download/postgresql-42.2.1.jre7.jar
>
> The result was basically the same, just a different nesting of the
> exceptions:
>
> DataIntegrityViolationException
> root cause: PSQLException: ... too many updates ...
>
> I was hoping an updated driver would help, but it appears to have the same
> issue.
>
> Regards,
> Chris
>
>
>
>
> --
> Sent from: http://www.postgresql-archive.org/PostgreSQL-jdbc-f2168246.html
>
>
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: MyBatis Batch Update Leads to PSQLException "Too many update results were returned"
@ 2018-03-04 14:34 Chris Dole <chris.dole@sas.com>
parent: Dave Cramer <pg@fastcrypt.com>
0 siblings, 1 reply; 6+ messages in thread
From: Chris Dole @ 2018-03-04 14:34 UTC (permalink / raw)
To: pgsql-jdbc
Hi Dave,
I am certainly willing to follow up on that, and will do so. I can turn on
debugging with MyBatis and perhaps capture the query pattern that is being
generated.
However, it would help to get some background on the PSQLException that is
being thrown.
* What is the nature of the error?
* What does Postgres or its JDBC driver imply about the query for the
message of "... too many updates ..."
* Can you give me an indication of what logic is being tripped over that
leads to this error condition?
Thanks,
Chris
--
Sent from: http://www.postgresql-archive.org/PostgreSQL-jdbc-f2168246.html
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: MyBatis Batch Update Leads to PSQLException "Too many update results were returned"
@ 2018-03-04 17:49 Dave Cramer <pg@fastcrypt.com>
parent: Chris Dole <chris.dole@sas.com>
0 siblings, 0 replies; 6+ messages in thread
From: Dave Cramer @ 2018-03-04 17:49 UTC (permalink / raw)
To: Chris Dole <chris.dole@sas.com>; +Cc: pgsql-jdbc
Dave Cramer
davec@postgresintl.com
www.postgresintl.com
On 4 March 2018 at 09:34, Chris Dole <chris.dole@sas.com> wrote:
> Hi Dave,
>
> I am certainly willing to follow up on that, and will do so. I can turn on
> debugging with MyBatis and perhaps capture the query pattern that is being
> generated.
>
> However, it would help to get some background on the PSQLException that is
> being thrown.
>
> * What is the nature of the error?
>
> * What does Postgres or its JDBC driver imply about the query for the
> message of "... too many updates ..."
>
> * Can you give me an indication of what logic is being tripped over that
> leads to this error condition?
>
I'd have to do some more investigation but start here.
https://github.com/pgjdbc/pgjdbc/blob/e6a1eccb148c3c59e8cf122e98ad01afc5bb555a/pgjdbc/src/main/java/...
>
> Thanks,
> Chris
>
>
>
>
> --
> Sent from: http://www.postgresql-archive.org/PostgreSQL-jdbc-f2168246.html
>
>
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2018-03-04 17:49 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-02-27 21:19 MyBatis Batch Update Leads to PSQLException "Too many update results were returned" Chris Dole <chris.dole@sas.com>
2018-03-02 21:05 ` Dave Cramer <pg@fastcrypt.com>
2018-03-02 21:13 ` Chris Dole <chris.dole@sas.com>
2018-03-04 13:48 ` Dave Cramer <pg@fastcrypt.com>
2018-03-04 14:34 ` Chris Dole <chris.dole@sas.com>
2018-03-04 17:49 ` Dave Cramer <pg@fastcrypt.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox