Don't pass QueryMetrics down in concurrent and async QueryRunners (fixes #4279)#4288
Don't pass QueryMetrics down in concurrent and async QueryRunners (fixes #4279)#4288
Conversation
|
@leventov can't we make QueryPlus threadsafe in general and not worry about what type of QueryRunner uses it? |
|
@himanshug it's not about |
|
@leventov i see, the confusion came from anyways, can't we require QueryMetrics instances to be thread-safe ? then "async" query runners do not need to do anything special. |
As I explained in my previous message, making Instead I suggest a structured, explicit approach.
|
|
ok, had a conversation with @leventov and concluded that following things be done.
|
…ueryPlus.withQueryMetrics() Javadocs; Fix generics in MetricsEmittingQueryRunner and CpuTimeMetricQueryRunner; Make DefaultQueryMetrics to fail fast on modifications from concurrent threads
QueryMetricsis unsafe for concurrent use from multiple threads, so it shouldn't be passed down in concurrent and async QueryRunners. Fixes #4279.This solution is safer than proposed in #3803 (metamx@54c2af2), but the issue raised in #3803: no difference between "sync" and "async" QueryRunners -- leaves this PR's solution fragile, because anyone who writes a new concurrent or async QueryRunner must know that he needs to call
queryPlus.threadSafe().