Skip to content

Commit 0d4ac65

Browse files
authored
Fix: cache issues (#292)
* restrict dev mode cache actions to 1 * Add check to open_tempdir in cache store that recreates tempdir if missing. * fix cache_server arg tooltip * add log cache to restart request monitoring task.
1 parent 93be3c3 commit 0d4ac65

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

docker-compose.development.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ services:
3131
- PREFETCH_RUNS_SINCE=2592000 # 30 days in seconds
3232
- PREFETCH_RUNS_LIMIT=1 # Prefetch only one run
3333
- S3_NUM_WORKERS=2
34-
- CACHE_ARTIFACT_MAX_ACTIONS=4
35-
- CACHE_DAG_MAX_ACTIONS=4
34+
- CACHE_ARTIFACT_MAX_ACTIONS=1
35+
- CACHE_DAG_MAX_ACTIONS=1
36+
- CACHE_LOG_MAX_ACTIONS=1
3637
- CACHE_ARTIFACT_STORAGE_LIMIT=16000000
3738
- CACHE_DAG_STORAGE_LIMIT=16000000
3839
- WS_POSTPROCESS_CONCURRENCY_LIMIT=8
@@ -62,6 +63,7 @@ services:
6263
volumes:
6364
- ./services:/root/services
6465
environment:
66+
- LOGLEVEL=WARNING
6567
- MF_METADATA_DB_HOST=db
6668
- MF_METADATA_DB_PORT=5432
6769
- MF_METADATA_DB_USER=postgres

services/ui_backend_service/data/cache/client/cache_server.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ def _error_callback(self, worker, res):
347347
help="Maximum number of concurrent cache actions.")
348348
@click.option("--max-size",
349349
default=10000,
350-
help="Maximum amount of disk space to use in MB.")
350+
help="Maximum amount of disk space to use in bytes.")
351351
def cli(root=None,
352352
max_actions=None,
353353
max_size=None):

services/ui_backend_service/data/cache/client/cache_store.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,17 @@ def mark_for_deletion(path, size):
181181
unmarked_size -= size
182182

183183
def ensure_path(self, path):
184+
"Ensures that the directory for a given path exists, creating it if missing."
184185
dirr = os.path.dirname(path)
186+
self.ensure_dir(dirr)
187+
188+
def ensure_dir(self, dirr):
189+
"Ensures that a directory exists, creating it if missing."
185190
if not os.path.isdir(dirr):
186191
try:
187192
makedirs(dirr)
188193
except Exception as ex:
189-
self.warn(ex, "Could not create dir: %s" % path)
194+
self.warn(ex, "Could not create dir: %s" % dirr)
190195

191196
def open_tempdir(self, token, action_name, stream_key):
192197
self._gc_objects()
@@ -198,7 +203,9 @@ def open_tempdir(self, token, action_name, stream_key):
198203
)
199204

200205
try:
201-
tmp = tempfile.mkdtemp(prefix="cache_action_%s." % token, dir=self.tmproot)
206+
self.ensure_dir(self.tmproot)
207+
tmp = tempfile.mkdtemp(prefix='cache_action_%s.' % token,
208+
dir=self.tmproot)
202209
except Exception as ex:
203210
msg = "Could not create a temp directory for request %s" % token
204211
self.warn(ex, msg)

services/ui_backend_service/data/cache/store.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ async def start_caches(self, app):
8383

8484
async def _monitor_restart_requests(self):
8585
while True:
86-
for _cache in [self.artifact_cache, self.dag_cache]:
86+
for _cache in [self.artifact_cache, self.dag_cache, self.log_cache]:
8787
if await _cache.restart_requested():
8888
cache_name = type(_cache).__name__
8989
logger.info("[{}] restart requested...".format(cache_name))

0 commit comments

Comments
 (0)