Commit 4a190b9
perf(ebean-dao): move SharedSchemaCache pre-warm to constructor (#618)
PR #615 introduced SharedSchemaCache with pre-warm calls inside
EbeanLocalAccess.ensureSchemaUpToDate(). In deploys where schema
migrations run as a separate job (LinkedIn's prod pattern, and likely
others), ensureSchemaUpToDate() is gated off, so pre-warm never runs
and the first request after JVM startup pays the inline
information_schema query cost (the "Inline schema cache miss" log
line).
Moves the pre-warm calls to the EbeanLocalAccess constructor so they
always run, regardless of whether schema evolution is enabled.
refreshTable() already has its own try/catch, so a transient DB
hiccup during construction logs a warning rather than failing boot.
Also drops the unused tableColumns field (dead code, replaced by the
shared cache in #615).
Two supporting changes:
1. SharedSchemaCache.clearRegistry() now also calls clearCaches() on
each held instance before wiping the REGISTRY map. Previously
clearing only the static map left stale entries readable through
any reference (e.g. EbeanLocalAccess.validator) that callers were
already holding -- a footgun that the @VisibleForTesting name did
not suggest.
2. EbeanLocalDAOTest.addIndex() helper now calls clearRegistry()
after its dynamic ALTER TABLE ADD COLUMN. With pre-warm now
running in the constructor, the cache snapshots the schema before
addIndex modifies it; the explicit invalidation keeps subsequent
columnExists()/indexExists() lookups in sync with the actual
table state.
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 56780a5 commit 4a190b9
3 files changed
Lines changed: 39 additions & 20 deletions
File tree
- dao-impl/ebean-dao/src
- main/java/com/linkedin/metadata/dao
- utils
- test/java/com/linkedin/metadata/dao
Lines changed: 21 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
46 | 45 | | |
47 | 46 | | |
48 | 47 | | |
| |||
83 | 82 | | |
84 | 83 | | |
85 | 84 | | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | 85 | | |
90 | 86 | | |
91 | 87 | | |
| |||
97 | 93 | | |
98 | 94 | | |
99 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
100 | 103 | | |
101 | 104 | | |
102 | 105 | | |
| |||
135 | 138 | | |
136 | 139 | | |
137 | 140 | | |
138 | | - | |
139 | | - | |
140 | | - | |
| 141 | + | |
141 | 142 | | |
142 | 143 | | |
143 | 144 | | |
| |||
254 | 255 | | |
255 | 256 | | |
256 | 257 | | |
257 | | - | |
| 258 | + | |
258 | 259 | | |
259 | 260 | | |
260 | 261 | | |
| |||
282 | 283 | | |
283 | 284 | | |
284 | 285 | | |
285 | | - | |
| 286 | + | |
286 | 287 | | |
287 | 288 | | |
288 | 289 | | |
| |||
292 | 293 | | |
293 | 294 | | |
294 | 295 | | |
295 | | - | |
| 296 | + | |
296 | 297 | | |
297 | 298 | | |
298 | 299 | | |
| |||
889 | 890 | | |
890 | 891 | | |
891 | 892 | | |
892 | | - | |
| 893 | + | |
893 | 894 | | |
894 | 895 | | |
895 | 896 | | |
896 | 897 | | |
897 | 898 | | |
898 | 899 | | |
899 | | - | |
| 900 | + | |
900 | 901 | | |
901 | 902 | | |
902 | 903 | | |
903 | 904 | | |
904 | 905 | | |
905 | 906 | | |
906 | | - | |
| 907 | + | |
907 | 908 | | |
908 | 909 | | |
909 | 910 | | |
| |||
969 | 970 | | |
970 | 971 | | |
971 | 972 | | |
972 | | - | |
| 973 | + | |
973 | 974 | | |
974 | 975 | | |
975 | 976 | | |
| |||
987 | 988 | | |
988 | 989 | | |
989 | 990 | | |
990 | | - | |
| 991 | + | |
991 | 992 | | |
992 | | - | |
| 993 | + | |
993 | 994 | | |
994 | 995 | | |
995 | 996 | | |
996 | | - | |
| 997 | + | |
997 | 998 | | |
998 | 999 | | |
999 | 1000 | | |
| |||
1016 | 1017 | | |
1017 | 1018 | | |
1018 | 1019 | | |
1019 | | - | |
| 1020 | + | |
1020 | 1021 | | |
1021 | | - | |
| 1022 | + | |
1022 | 1023 | | |
1023 | 1024 | | |
1024 | 1025 | | |
1025 | | - | |
| 1026 | + | |
1026 | 1027 | | |
1027 | 1028 | | |
1028 | 1029 | | |
| |||
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
213 | 220 | | |
214 | 221 | | |
215 | 222 | | |
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4133 | 4133 | | |
4134 | 4134 | | |
4135 | 4135 | | |
| 4136 | + | |
4136 | 4137 | | |
4137 | 4138 | | |
4138 | 4139 | | |
| 4140 | + | |
4139 | 4141 | | |
4140 | 4142 | | |
4141 | 4143 | | |
| |||
4144 | 4146 | | |
4145 | 4147 | | |
4146 | 4148 | | |
| 4149 | + | |
| 4150 | + | |
| 4151 | + | |
| 4152 | + | |
| 4153 | + | |
| 4154 | + | |
| 4155 | + | |
| 4156 | + | |
| 4157 | + | |
4147 | 4158 | | |
4148 | 4159 | | |
4149 | 4160 | | |
| |||
0 commit comments