Skip to content

Commit 2da8005

Browse files
committed
Increase Solr cache write timeout to 30s (configurable)
1 parent 95a061a commit 2da8005

4 files changed

Lines changed: 21 additions & 2 deletions

File tree

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@ EXPOSE 8080
2222
# VFBQUERY_MAX_CONCURRENT (default: workers × 2)
2323
# VFBQUERY_MAX_QUEUE_DEPTH (default: 200, 0 = unlimited)
2424
# VFBQUERY_CACHE_TTL (default: 300 seconds)
25+
# VFBQUERY_SOLR_WRITE_TIMEOUT (default: 30 seconds)
2526

2627
ENTRYPOINT ["python", "-m", "vfbquery.ha_api"]

release_notes.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
## What's Changed (v1.6.13)
2+
3+
### Increased Solr cache write timeout
4+
5+
Solr cache writes are performed asynchronously after the query returns to the user.
6+
We now default to a **30 second write timeout** (configurable via `VFBQUERY_SOLR_WRITE_TIMEOUT`).
7+
8+
This helps prevent large or slow cache writes from spamming errors while still allowing the cache to work when Solr is responsive.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
here = path.abspath(path.dirname(__file__))
55

6-
__version__ = "1.6.12"
6+
__version__ = "1.6.13"
77

88
# Get the long description from the README file
99
with open(path.join(here, 'README.md')) as f:

src/vfbquery/solr_result_cache.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,16 @@ def __init__(self,
7373
self._solr_disabled_until = 0.0 # epoch timestamp
7474
self._solr_backoff_seconds = int(os.getenv('VFBQUERY_SOLR_BACKOFF_SECONDS', '60'))
7575
self._solr_last_error = None
76+
77+
@property
78+
def solr_cache_enabled(self) -> bool:
79+
"""True if Solr caching is currently enabled."""
80+
return not self._solr_disabled
81+
82+
@property
83+
def solr_cache_disabled_until(self) -> float:
84+
"""Epoch timestamp when Solr caching will be retried (or 0 if enabled)."""
85+
return self._solr_disabled_until
7686

7787
def _create_cache_metadata(self, result: Any, **params) -> Optional[Dict[str, Any]]:
7888
"""Create metadata for cached result with 3-month expiration"""
@@ -313,7 +323,7 @@ def cache_result(self, query_type: str, term_id: str, result: Any, **params) ->
313323
data=json.dumps([cache_doc]),
314324
headers={"Content-Type": "application/json"},
315325
params={"commit": "true"}, # Immediate commit for availability
316-
timeout=10
326+
timeout=int(os.getenv('VFBQUERY_SOLR_WRITE_TIMEOUT', '30'))
317327
)
318328

319329
if response.status_code == 200:

0 commit comments

Comments
 (0)