Commit c4f29a5
committed
Stop SOLR cache write storm: gate @with_solr_cache on env flag + back off on 5xx
Two related fixes for the cache-layer behaviour that's been flooding CI
logs with "Failed to cache result: HTTP 500" and adding ~200-300ms per
query while the SOLR vfb_json core has a broken Lucene index
(`/var/solr/data/vfb_json/data/index/_3koa1.fdm: Input/output error` →
`IndexWriter is closed`).
1) `@with_solr_cache` was firing unconditionally. The __init__.py guard
only gated the second-layer `patch_vfbquery_with_caching()` patch,
but the @with_solr_cache decorator is applied at module-import time
to functions in vfb_queries.py (term_info, instances, templates,
neurons_part_here, etc.) and was running its full cache write/read
path even when VFBQUERY_CACHE_ENABLED=false. With caching disabled
on a broken SOLR backend, every call still made the failing write
attempt. Fix: respect the env flag inside the wrapper — if disabled,
pop force_refresh (so the wrapped function doesn't see a stray
kwarg it can't accept) and call straight through.
2) cache_result() backed off only on `Exception`. HTTP 5xx responses
(Lucene IndexWriter closed, SOLR proxy 502/503) hit the `else:`
branch which just logged and returned False — every subsequent call
re-attempted the same write, hitting the same 5xx, costing 200-300ms
each time and producing a multi-KB stack trace per call. Fix: treat
any 5xx as cause to set _solr_disabled and start the same backoff
window the exception path uses. 4xx still logs once but doesn't
disable (likely a payload/config issue, not server-down).
Net effect on the python-test workflow:
- VFBQUERY_CACHE_ENABLED=false → no cache writes attempted at all
- VFBQUERY_CACHE_ENABLED=true on a broken backend → one warning, then
fast-fail for the backoff window
Server-side: the broken Lucene segment on the SOLR vfb_json core is a
separate sysadmin issue (filesystem I/O error on the SOLR host). This
PR doesn't fix it, but it stops the failure from cascading into every
test run.
Refs: PR #41 CI logs showing the storm.1 parent ef2b11b commit c4f29a5
1 file changed
Lines changed: 39 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
391 | 391 | | |
392 | 392 | | |
393 | 393 | | |
394 | | - | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
395 | 419 | | |
396 | | - | |
| 420 | + | |
397 | 421 | | |
398 | 422 | | |
399 | 423 | | |
| |||
766 | 790 | | |
767 | 791 | | |
768 | 792 | | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
769 | 805 | | |
770 | 806 | | |
771 | | - | |
| 807 | + | |
772 | 808 | | |
773 | 809 | | |
774 | 810 | | |
| |||
0 commit comments