Skip to content

Cache all handler-reachable queries (v1.19.0)#45

Merged
Robbie1977 merged 1 commit into
mainfrom
feature/cache-all-queries
Jun 8, 2026
Merged

Cache all handler-reachable queries (v1.19.0)#45
Robbie1977 merged 1 commit into
mainfrom
feature/cache-all-queries

Conversation

@Robbie1977

Copy link
Copy Markdown
Contributor

Completes the half-finished SOLR result-cache migration so every query-result
function reachable from the HA API handlers is served from the persistent cache
instead of recomputing against Neo4j/Owlery on each call.

What changed

  • Decorate the 14 missing cacheable *_cached wrappers (transcriptomics, the
    similar_morphology sub-types, dataset/image and transgene queries,
    individual_neuron_inputs). get_similar_morphology_userdata left uncached
    (per-session upload id).
  • Register the five new buckets in expensive_query_types and
    dataframe_query_types so limited requests slice from the cached full
    result; add an all_datasets fixed-key branch for the no-id case.
  • Persist query_connectivity behind the in-memory cache via a hashed
    composite key over all five parameters; graph post_fn stays out of the
    cached payload; force_refresh wired through handler and worker.
  • Default the cache to the dedicated query-cache Solr
    http://vfbquerycache.virtualflybrain.org:80/solr/vfb_json (port 80; the
    native Solr port is firewalled externally), with a VFBQUERY_SOLR_URL
    override. Data reads in vfb_queries.py are unchanged.
  • Bump to 1.19.0 so the major.minor cache key rotates on deploy.

No bucket renames (cache keys stay stable); force_refresh=true still bypasses
and invalidates.

Verification

  • Coverage sweep traced from the handlers: 12 uncached entry points -> 0.
  • Cache-hit proofs against real Neo4j/Owlery (cache pointed at a local stub, no
    prod writes): cold->warm speed-ups 46x-2790x across five query types incl.
    query_connectivity; force_refresh recompute confirmed.
  • test_graph_builder (36) and test_ha_api_validation (7) pass. The one
    failover test failure pre-exists on main.

Note for reviewer
The new cache host was read-verified only; a cache write to it was not tested
(production core, not staging). Confirm a vfb_query_* doc lands there after
deploy, or test against a staging core via VFBQUERY_SOLR_URL first. The old
default solr.virtualflybrain.org core was returning HTTP 500 on writes
(write.lock: Input/output error), which moving the cache off it should fix.

Complete the half-finished migration that left most query functions
recomputing against Neo4j/Owlery on every call. Tracing from the ha_api
handlers (not just cached_functions.py) showed 12 handler-reachable
functions with no @with_solr_cache at either layer, plus the
cross-dataset query_connectivity persisted only in the per-container
in-memory cache.

- Decorate the missing cacheable *_cached wrappers (cluster_expression,
  expression_cluster, scrnaseq_dataset_data, individual_neuron_inputs,
  the similar_morphology family, dataset_images, all_aligned_images,
  all_datasets, transgene_expression_here, related_anatomy). Leave
  similar_morphology_userdata uncached (per-session upload id).
- Register the five new buckets in expensive_query_types and
  dataframe_query_types so limited requests slice from the cached full
  result, and add an all_datasets fixed-key branch for the no-id case.
- Persist query_connectivity behind the in-memory cache using a hashed
  composite key over all five parameters; keep graph post_fn out of the
  cached payload; wire force_refresh through the handler and worker.
- Bump to 1.19.0 so the major.minor cache key rotates on deploy.
- Default SolrResultCache to http://vfbquerycache.virtualflybrain.org:80/solr/vfb_json
  (the dedicated query-cache Solr; port 80 because the Solr native port is
  firewalled externally) instead of solr.virtualflybrain.org. Add a
  VFBQUERY_SOLR_URL env override. Data reads in vfb_queries.py are unchanged.

No bucket renames (cache keys are stable); force_refresh still bypasses
and invalidates. Coverage sweep: 12 uncached handler entry points -> 0.
@Robbie1977 Robbie1977 merged commit 3a2bfc8 into main Jun 8, 2026
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant