You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The rates are loaded from the DB at worker startup (bootstrap()). However, once loaded, they are never refreshed. So, if the worker runs for many days/weeks/months, then checks that contain recent data won’t be able to perform currency conversion.
import_data loads the rates into global variables, which are then accessed by all threads. As such, a solution that involves running import_data again would not be thread-safe.
workers/extract/kingfisher_process runs update_from_fixer_io, which adds rates to the DB. However, the other workers will have already bootstrapped the data, and so updating the rates here has no effect on active workers.
Things done so far:
Add an update-exchange-rates command, currently scheduled to run twice a day (can change to once), to update the rates in the DB.
Process-level options:
Do nothing. Currency extrapolation already works. Workers will be restarted occasionally through normal operations.
Restart workers on a regular basis (either daily or weekly) with a cronjob (docker-compose down and up -d)
Code-level options (can do one or more):
This is mainly about making the existing code thread-safe.
Instead of running clear() in import_data, just assign the new values to the globals once computed.
Add a way to incrementally update the in-memory cache.
Auto-expire the in-memory cache (e.g. using a @cachetools decorator or a ttl on a memcache key).
Adopt memcached as part of this.
The text was updated successfully, but these errors were encountered:
Problems:
bootstrap()
). However, once loaded, they are never refreshed. So, if the worker runs for many days/weeks/months, then checks that contain recent data won’t be able to perform currency conversion.import_data
loads the rates into global variables, which are then accessed by all threads. As such, a solution that involves runningimport_data
again would not be thread-safe.workers/extract/kingfisher_process
runsupdate_from_fixer_io
, which adds rates to the DB. However, the other workers will have already bootstrapped the data, and so updating the rates here has no effect on active workers.Things done so far:
update-exchange-rates
command, currently scheduled to run twice a day (can change to once), to update the rates in the DB.Process-level options:
docker-compose down
andup -d
)Code-level options (can do one or more):
This is mainly about making the existing code thread-safe.
clear()
inimport_data
, just assign the new values to the globals once computed.@cachetools
decorator or a ttl on a memcache key).The text was updated successfully, but these errors were encountered: