Uploaded image for project: 'Beam'
  1. Beam
  2. BEAM-793

JdbcIO can create a deadlock when parallelism is greater than 1

Details

    • Bug
    • Status: Resolved
    • P3
    • Resolution: Fixed
    • None
    • 2.3.0
    • io-java-jdbc
    • None

    Description

      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.

              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);
                                  }
                              }));
      

      This can happen due to the autocommit. I'm going to investigate.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jbonofre Jean-Baptiste Onofré
              Votes:
              1 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 4h 20m
                  4h 20m