Commit 5805534
committed
Fix NPE when retried query reuses stale FragmentInstanceContext
When QueryExecution.retry() re-plans a query, doDistributionPlan()
creates fresh PlanFragmentId objects with nextFragmentInstanceId reset
to 0. Because the queryId is unchanged, retry generates fragment
instance IDs identical to the first execution (e.g. queryId_11.0).
FragmentInstanceManager.instanceContext retains completed contexts for
5 minutes for statistics caching. When a retry dispatches the same FI
ID, instanceContext.computeIfAbsent() returns the stale old context
whose releaseResource() has already been called, setting dataRegion to
null. New drivers then NPE at dataRegion.tryReadLock() inside
FragmentInstanceContext.initQueryDataSource().
Fix: replace computeIfAbsent() with compute() in
execDataQueryFragmentInstance() so that a released context
(dataRegion == null) is atomically replaced with a fresh one carrying
the new dataRegion reference.
Defensive fix: add a null guard for dataRegion in
getSharedQueryDataSource() that returns null (treated by DataDriver as
an aborted FI) instead of propagating NPE.1 parent 9d72f66 commit 5805534
2 files changed
Lines changed: 23 additions & 11 deletions
File tree
- iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/fragment
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
781 | 781 | | |
782 | 782 | | |
783 | 783 | | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
784 | 788 | | |
785 | 789 | | |
786 | 790 | | |
| |||
Lines changed: 19 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
154 | 160 | | |
155 | | - | |
| 161 | + | |
156 | 162 | | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
167 | 175 | | |
168 | 176 | | |
169 | 177 | | |
| |||
0 commit comments