Commit e5f49e8
Fix/optionset preheat n1 master (#24850)
* feat: add valid-option-code storage to TrackerPreheat
Adds per-option-set valid-code and resolved-set tracking so validators
and the ASSIGN-action pipeline can check option codes without
materializing the full OptionSet.options collection.
* feat: add OptionValueSupplier, preheat only referenced option codes
Queries optionvalue directly for the (option set, code) pairs actually
referenced by the import payload, in chunks, instead of relying on
OptionSetMapper to hydrate entire option collections. Cost is bounded
by distinct codes referenced, not option set size.
Includes the NOSONAR suppression for the two-phase collect/query loop
(false positive: confirmed is populated by the query immediately
before it's read).
* feat: validate option codes against preheated OptionValueSupplier data
Switches validateOptionSet() to check TrackerPreheat's valid-code cache
instead of scanning OptionSet.getOptions(), with a diagnostic log.warn
when an option set never got resolved during preheat. Updates all
three call sites (tracked entity, enrollment, and event attribute/data
value validators) and their tests accordingly.
* perf: stop preheat from fully materializing OptionSet.options
OptionSetMapper no longer maps the options collection, which was
forcing a full lazy-collection load (and JSONB deserialization of
every option) for every OptionSet touched during tracker preheat.
Callers now go through OptionValueSupplier/TrackerPreheat instead.
* fix: resolve option codes introduced by program rule ASSIGN actions
ASSIGN actions can introduce data element/attribute values that were
never part of the original import payload, so OptionValueSupplier's
single preheat pass can't have seen their option codes. Runs the
assigned values back through OptionValueSupplier as a synthetic
TrackerObjects before validation, so option-set validation still sees
them as preheated.
Adds getter access to the executors' resolved data element/attribute
UID and value, and asserts no errors in the previously-unchecked
option-value ASSIGN warning test.
* test: remove redundant public visibility modifier in AttributeValidatorTest
SonarQube java:S5786 -- JUnit5 lifecycle methods don't need public visibility.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* test: prove OptionValueSupplier can't validate a fabricated cross-option-set pair
The two-column IN/IN query in queryChunk() can return rows whose optionsetid
and code each satisfy one of the two independent IN-lists without the pair
itself ever having been requested. Correctness depends entirely on the
in-memory confirmed.contains(pair) check filtering those out before anything
is marked valid. Add a regression test that mocks a query result covering
that exact cross-contamination shape and confirms the fabricated pairs stay
unvalidated while a genuine pair still passes; verified by temporarily
weakening the check and watching this test fail.
* fix: use unnest parallel-array join in OptionValueSupplier
Switches the (optionsetid, code) lookup from IN (...) AND IN (...) to a
join against unnest(?::bigint[], ?::text[]), per @teleivo/@ameenhere's
review on #24850. The IN/IN form only sargs on the leading index column
once cardinality grows, downgrading `code` to a post-scan Filter; the
unnest join keeps both columns in the Index Cond via
optionvalue_unique_optionsetid_and_code regardless of scale.
---------
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>1 parent af68eda commit e5f49e8
17 files changed
Lines changed: 842 additions & 74 deletions
File tree
- dhis-2
- dhis-test-integration/src/test/java/org/hisp/dhis/tracker/imports/programrule
- dhis-tracker/src
- main/java/org/hisp/dhis/tracker/imports
- bundle
- config
- preheat
- mappers
- supplier
- programrule/executor
- enrollment
- event
- validation/validator
- enrollment
- event
- trackedentity
- test/java/org/hisp/dhis/tracker/imports
- preheat
- supplier
- validation/validator
- enrollment
- event
- trackedentity
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
308 | 308 | | |
309 | 309 | | |
310 | 310 | | |
| 311 | + | |
| 312 | + | |
311 | 313 | | |
312 | 314 | | |
313 | 315 | | |
| |||
Lines changed: 102 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
37 | 40 | | |
38 | 41 | | |
39 | 42 | | |
40 | 43 | | |
| 44 | + | |
41 | 45 | | |
42 | 46 | | |
43 | 47 | | |
| 48 | + | |
44 | 49 | | |
45 | 50 | | |
46 | 51 | | |
47 | 52 | | |
48 | 53 | | |
49 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
50 | 58 | | |
| 59 | + | |
51 | 60 | | |
52 | 61 | | |
53 | 62 | | |
54 | 63 | | |
| 64 | + | |
55 | 65 | | |
| 66 | + | |
| 67 | + | |
56 | 68 | | |
57 | 69 | | |
58 | 70 | | |
| |||
77 | 89 | | |
78 | 90 | | |
79 | 91 | | |
| 92 | + | |
| 93 | + | |
80 | 94 | | |
81 | 95 | | |
82 | 96 | | |
| |||
97 | 111 | | |
98 | 112 | | |
99 | 113 | | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
100 | 117 | | |
101 | 118 | | |
102 | 119 | | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
103 | 204 | | |
104 | 205 | | |
105 | 206 | | |
| |||
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
| |||
56 | 57 | | |
57 | 58 | | |
58 | 59 | | |
| 60 | + | |
59 | 61 | | |
60 | 62 | | |
61 | 63 | | |
| |||
Lines changed: 37 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
141 | 177 | | |
142 | 178 | | |
143 | 179 | | |
| |||
Lines changed: 8 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
33 | | - | |
34 | 32 | | |
35 | 33 | | |
36 | 34 | | |
37 | 35 | | |
38 | | - | |
39 | 36 | | |
40 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
41 | 45 | | |
42 | 46 | | |
43 | 47 | | |
| |||
47 | 51 | | |
48 | 52 | | |
49 | 53 | | |
50 | | - | |
51 | 54 | | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | 55 | | |
0 commit comments