From 4b51dd9ba5b5b0a04dc28775ac6868d08c2a098e Mon Sep 17 00:00:00 2001 From: Ian Renton Date: Fri, 18 Sep 2026 18:57:18 +0100 Subject: [PATCH] (Hopefully) fix a bug where several sig ref data providers try to write to the data store simultaneously on startup. --- providers/sigrefdata/sig_ref_data_provider.py | 6 ++++-- templates/add_spot.html | 2 +- templates/alerts.html | 2 +- templates/bands.html | 4 ++-- templates/base.html | 10 +++++----- templates/conditions.html | 2 +- templates/map.html | 4 ++-- templates/spots.html | 4 ++-- templates/status.html | 2 +- 9 files changed, 19 insertions(+), 17 deletions(-) diff --git a/providers/sigrefdata/sig_ref_data_provider.py b/providers/sigrefdata/sig_ref_data_provider.py index bf128a9..a718bf5 100644 --- a/providers/sigrefdata/sig_ref_data_provider.py +++ b/providers/sigrefdata/sig_ref_data_provider.py @@ -36,8 +36,10 @@ class SIGRefDataProvider: def _add_data(self, new_data): """Add all the provided reference data objects to the data store.""" - # with transact() batches all writes together to save making thousands of individual sqlite writes - with DATA_STORE.sigrefs.transact(): + # with transact() batches all writes together to save making thousands of individual sqlite writes. However, + # that means that each provider holds the lock while it writes, and the default behaviour for other attempted + # transact()s is to fail if they can't get the lock (?!). This behaviour is fixed by retry=True. + with DATA_STORE.sigrefs.transact(retry=True): for d in new_data: DATA_STORE.sigrefs.set(f"{self.sig_name}:{d.id}", d) diff --git a/templates/add_spot.html b/templates/add_spot.html index f17337d..0a182db 100644 --- a/templates/add_spot.html +++ b/templates/add_spot.html @@ -77,7 +77,7 @@ - + diff --git a/templates/alerts.html b/templates/alerts.html index 3991040..b6dc4d8 100644 --- a/templates/alerts.html +++ b/templates/alerts.html @@ -83,7 +83,7 @@ - + diff --git a/templates/bands.html b/templates/bands.html index 5a68601..cf1ab35 100644 --- a/templates/bands.html +++ b/templates/bands.html @@ -76,8 +76,8 @@ - - + + diff --git a/templates/base.html b/templates/base.html index 184e8e6..61b7f49 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,6 +1,6 @@ {% extends "skeleton.html" %} {% block head_extra %} - + @@ -16,10 +16,10 @@ window.fetchEventSource = fetchEventSource; - - - - + + + + {% end %} {% block body %}
diff --git a/templates/conditions.html b/templates/conditions.html index f91d21d..e19356e 100644 --- a/templates/conditions.html +++ b/templates/conditions.html @@ -284,7 +284,7 @@
- + diff --git a/templates/map.html b/templates/map.html index 90d8e5e..494222b 100644 --- a/templates/map.html +++ b/templates/map.html @@ -113,8 +113,8 @@ const CARTODB_API_KEY = "{{ web_ui_options.get('cartodb_api_key', '') }}"; - - + + diff --git a/templates/spots.html b/templates/spots.html index 111cd3e..4c781e7 100644 --- a/templates/spots.html +++ b/templates/spots.html @@ -125,8 +125,8 @@ - - + + diff --git a/templates/status.html b/templates/status.html index 3e516d0..5f0d879 100644 --- a/templates/status.html +++ b/templates/status.html @@ -96,7 +96,7 @@ - +