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

ConcurrentModificationException from RowCoderGenerator lazy caching

Details

    • Bug
    • Status: Resolved
    • P2
    • Resolution: Fixed
    • None
    • 2.7.1
    • sdk-java-core

    Description

      Summary:

      RowCoderGenerator caches a delegate Coder<Row> once encode or decode is exercised, but there's not an API for caching this delegate eagerly.

      Use Case:

      When creating several PCollections to perform distinct reads with the same schema, you might create one RowCoder.of(schema) before creating the list of PCollections / PCollectionsList. However, once the pipeline begins and rows arrive for encoding, these pipelines will simultaneously try to cache a delegate coder for the row's schema. 

      Workaround:

      You can force the eager caching of the code by exercising encode in the main application before creating PCollections using the RowCoder:

      try {
       myRowCoder.encode(null, null);
       } catch (IOException | NullPointerException e) {
       // do nothing
      }
      

      Context:

      I've only encountered this during development with the direct runner.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              bhtucker Benson Tucker
              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 - 1h 10m
                  1h 10m