You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@beam.apache.org by "Maxim Ivanov (Jira)" <ji...@apache.org> on 2021/02/26 12:57:00 UTC

[jira] [Commented] (BEAM-793) JdbcIO can create a deadlock when parallelism is greater than 1

    [ https://issues.apache.org/jira/browse/BEAM-793?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17291630#comment-17291630 ] 

Maxim Ivanov commented on BEAM-793:
-----------------------------------

[~robert@fluidly.com], [~igosuki] , regarding SQL code for deadlock, any class 40 code should trigger retry:


|{{40000}}|{{transaction_rollback}}|
|{{40002}}|{{transaction_integrity_constraint_violation}}|
|{{40001}}|{{serialization_failure}}|
|{{40003}}|{{statement_completion_unknown}}|
|{{40P01}}|{{deadlock_detected}}|

> JdbcIO can create a deadlock when parallelism is greater than 1
> ---------------------------------------------------------------
>
>                 Key: BEAM-793
>                 URL: https://issues.apache.org/jira/browse/BEAM-793
>             Project: Beam
>          Issue Type: Bug
>          Components: io-java-jdbc
>            Reporter: Jean-Baptiste Onofré
>            Priority: P3
>             Fix For: 2.3.0
>
>          Time Spent: 4h 20m
>  Remaining Estimate: 0h
>
> With the following JdbcIO configuration, if the parallelism is greater than 1, we can have a {{Deadlock found when trying to get lock; try restarting transaction}}.
> {code}
>         MysqlDataSource dbCfg = new MysqlDataSource();
>         dbCfg.setDatabaseName("db");
>         dbCfg.setUser("user");
>         dbCfg.setPassword("pass");
>         dbCfg.setServerName("localhost");
>         dbCfg.setPortNumber(3306);
>         p.apply(Create.of(data))
>                 .apply(JdbcIO.<Tuple5<Integer, Integer, ByteString, Long, Long>>write()
>                         .withDataSourceConfiguration(JdbcIO.DataSourceConfiguration.create(dbCfg))
>                         .withStatement("INSERT INTO smth(loc,event_type,hash,begin_date,end_date) VALUES(?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE event_type=VALUES(event_type),end_date=VALUES(end_date)")
>                         .withPreparedStatementSetter(new JdbcIO.PreparedStatementSetter<Tuple5<Integer, Integer, ByteString, Long, Long>>() {
>                             public void setParameters(Tuple5<Integer, Integer, ByteString, Long, Long> element, PreparedStatement statement)
>                                     throws Exception {
>                                 statement.setInt(1, element.f0);
>                                 statement.setInt(2, element.f1);
>                                 statement.setBytes(3, element.f2.toByteArray());
>                                 statement.setLong(4, element.f3);
>                                 statement.setLong(5, element.f4);
>                             }
>                         }));
> {code}
> This can happen due to the {{autocommit}}. I'm going to investigate.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)