Skip to content

Concurrent modification of responseContext in QueryRunners #3803

@leventov

Description

@leventov

responseContext is a plain HashMap. It is accessed/modified concurrently without any synchronization in AsyncQueryRunner, IntervalChunkingQueryRunner, ChainedExecutionQueryFactory, etc.

We didn't notice this problem before, because responseContext had very limited use, but as part of #3798 I started to use responseContexts more extensively and got ConcurrentModificationException.

I quickly fixed this in this commit: metamx@54c2af2 but I don't like this solution, especially how it works in AsyncQueryRunner and DirectDruidClient, because it is super fragile and relies on what particular types of QueryRunners call AsyncQueryRunner and called from DirectDruidClient. There are two main problems:

  • it is not specified how responseContext could and could not be used and when it is "finalized": after return from QueryRunner.run(), or after iteration over the returned Sequence is completed.
  • No difference between "sync" and "async" (lazy) QueryRunners/Sequences

I don't have an idea yet what a better solution would be.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions