From 4e8667c4316e512a709c46c5a96093adb9c7b0ec Mon Sep 17 00:00:00 2001 From: r0ps3c Date: Fri, 22 Jan 2021 05:48:19 -0500 Subject: [PATCH] Fix upload thread creation timing issue (#240) If the block cache is initialised (i.e. associated threads created, with references to trio channels) before daemonisation, those threads end up running in a separate process to the main trio code and thus sending/receiving on two unrelated/"disconnected" channels. Fix this by moving initialisation back after daemonisation, as was the case before the commit in fbd3116 --- Changes.txt | 5 ++++- src/s3ql/mount.py | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Changes.txt b/Changes.txt index 2053b52b4..d0e04d7b6 100644 --- a/Changes.txt +++ b/Changes.txt @@ -2,8 +2,11 @@ UNRELEASED CHANGES * The tcp-timeout backend option of the B2 Backend works now. + * mount.s3ql no longer crashes with "No Upload Threads available" when not running in + foreground. -2021-01-03, S3Ql 3.7.0 + +2021-01-03, S3QL 3.7.0 * S3QL now requires Python 3.7 or newer. diff --git a/src/s3ql/mount.py b/src/s3ql/mount.py index 6ae73a5f3..00a14a04d 100644 --- a/src/s3ql/mount.py +++ b/src/s3ql/mount.py @@ -204,7 +204,6 @@ async def main_async(options, stdout_log_handler): async with AsyncExitStack() as cm: block_cache = BlockCache(backend_pool, db, cachepath + '-cache', options.cachesize * 1024, options.max_cache_entries) - block_cache.init(options.threads) cm.push_async_callback(block_cache.destroy, options.keep_cache) operations = fs.Operations(block_cache, db, max_obj_size=param['max_obj_size'], @@ -240,6 +239,8 @@ def unmount(): mark_metadata_dirty(backend, cachepath, param) + block_cache.init(options.threads) + nursery.start_soon(metadata_upload_task.run, name='metadata-upload-task') cm.callback(metadata_upload_task.stop)