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

JdbcIO: Improve connection management

Details

    • Improvement
    • Status: Resolved
    • P2
    • Resolution: Fixed
    • 2.2.0
    • 2.5.0
    • io-java-jdbc
    • None

    Description

      JdbcIO write DoFn acquires connection in @Setup and release it in @Teardown methods, which means that connection might stay opened for days in streaming job case. Keeping single connection open for so long might be very risky as it's exposed to database, network etc issues.

      Taking connection from the pool when it is actually needed

      I suggest that connection would be taken from the connection pool in executeBatch method and released when the batch is flushed. This will allow the pool to take care of any returned unhealthy connections etc.

      Make JdbcIO accept data source factory
      It would be nice if JdbcIO accepted DataSourceFactory rather than DataSource itself. I am saying that because sink checks if DataSource implements `Serializable` interface, which make it impossible to pass BasicDataSource(used internally by sink) as it doesn’t implement this interface. Something like:

      interface DataSourceFactory extends Serializable{
           DataSource create();
      }
      

      Attachments

        Activity

          People

            jbonofre Jean-Baptiste Onofré
            pawelbartoszek Pawel Bartoszek
            Votes:
            0 Vote for this issue
            Watchers:
            3 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 - 7.5h
                7.5h