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

Spanner Session leak/overload in Streaming Dataflow

Details

    • Bug
    • Status: Resolved
    • P2
    • Resolution: Fixed
    • 2.18.0, 2.19.0, 2.21.0, 2.22.0
    • 2.23.0
    • io-java-gcp

    Description

      SpannerIO.WriteToSpannerFn connects to Spanner every time @Setup is called, and closes the connection every time @Teardown is called.

      This actually creates a separate Spanner connection and session pool for each WriteToSpannerFn, which generally speaking is one per thread

      In single-threaded runners (eg batch dataflow on a single vCPU machine) this is not an issue, as there is normally only one WriteToSpannerFn per node/process.

      In multi-threaded runners (eg streaming dataflow, or batch on multiple CPU machines), this can cause a problem with many session pools created (1 per thread) which can cause a respource leak, and is in general wasteful.

      Spanner connections (and session pools) should be shared among all threads of a single process. so that the connection is only opened and closed once.

      alxavier

      Attachments

        Issue Links

          Activity

            People

              nielm Niel Markwick
              nielm Niel Markwick
              Votes:
              0 Vote for this issue
              Watchers:
              1 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 - 2h 40m
                  2h 40m