Skip to content

Apparent concurrecy issues when recap and start try both to access the same DB table #135

@fishinthecalculator

Description

@fishinthecalculator

This happened in production when both jobs run at 11:00AM

mobilizon-reshare_1  | [2022-01-31 11:00:00,087] [20] [INFO] Running job "partial (trigger: cron[day_of_week='mon-fri', hour='10-18', minute='*/15'], next run at: 2022-01-31 11:15:00 CET)" $
scheduled at 2022-01-31 11:00:00+01:00)
mobilizon-reshare_1  | [2022-01-31 11:00:00,097] [20] [INFO] Updating database to latest version
mobilizon-reshare_1  | [2022-01-31 11:00:00,098] [20] [INFO] Tortoise-ORM shutdown
mobilizon-reshare_1  | [2022-01-31 11:00:00,101] [20] [INFO] Running job "partial (trigger: cron[day_of_week='mon', hour='11'], next run at: 2022-02-07 11:00:00 CET)" (scheduled at 2022-01-3
1 11:00:00+01:00)
mobilizon-reshare_1  | [2022-01-31 11:00:00,105] [20] [INFO] Updating database to latest version
mobilizon-reshare_1  | [2022-01-31 11:00:00,105] [20] [INFO] Tortoise-ORM shutdown
mobilizon-reshare_1  | [2022-01-31 11:00:00,134] [20] [INFO] Tortoise-ORM shutdown
mobilizon-reshare_1  | [2022-01-31 11:00:00,136] [20] [INFO] Tortoise-ORM shutdown
mobilizon-reshare_1  | [2022-01-31 11:00:00,159] [40] [ERROR] Job "partial (trigger: cron[day_of_week='mon', hour='11'], next run at: 2022-02-07 11:00:00 CET)" raised an exception
mobilizon-reshare_1  | Traceback (most recent call last):
mobilizon-reshare_1  |   File "/gnu/store/bywwh03n04bacn3379d3jn522225k3fq-python-apscheduler-3.6.3/lib/python3.9/site-packages/apscheduler/executors/base_py3.py", line 29, in run_coroutine_
job
mobilizon-reshare_1  |     retval = await job.func(*job.args, **job.kwargs)
mobilizon-reshare_1  |   File "/gnu/store/3j6dy8isc167lnzcwdcrvazzpznjj39b-mobilizon-reshare.git-0.1.0-0.ed8caaf/lib/python3.9/site-packages/mobilizon_reshare/cli/__init__.py", line 26, in _
safe_execution
mobilizon-reshare_1  |     await init()
mobilizon-reshare_1  |   File "/gnu/store/3j6dy8isc167lnzcwdcrvazzpznjj39b-mobilizon-reshare.git-0.1.0-0.ed8caaf/lib/python3.9/site-packages/mobilizon_reshare/cli/__init__.py", line 22, in i
nit
mobilizon-reshare_1  |     await db.setup()
mobilizon-reshare_1  |   File "/gnu/store/3j6dy8isc167lnzcwdcrvazzpznjj39b-mobilizon-reshare.git-0.1.0-0.ed8caaf/lib/python3.9/site-packages/mobilizon_reshare/storage/db.py", line 81, in set
up
mobilizon-reshare_1  |     await update_publishers(publisher_names)
mobilizon-reshare_1  |   File "/gnu/store/bnyqyw1j8cdqvbdakblhj543fi6lh73x-python-tortoise-orm-0.18.1/lib/python3.9/site-packages/tortoise/transactions.py", line 60, in wrapped
mobilizon-reshare_1  |     return await func(*args, **kwargs)
mobilizon-reshare_1  |   File "/gnu/store/bnyqyw1j8cdqvbdakblhj543fi6lh73x-python-tortoise-orm-0.18.1/lib/python3.9/site-packages/tortoise/backends/base/client.py", line 243, in __aexit__
mobilizon-reshare_1  |     current_transaction_map[self.connection_name].reset(self.token)
mobilizon-reshare_1  | ValueError: <Token var=<ContextVar name='default' default=<tortoise.backends.sqlite.client.SqliteClient object at 0x7fd28cb16460> at 0x7fd28dc1b1d0> at 0x7fd28dd82ec0>
 was created by a different ContextVar
mobilizon-reshare_1  | [2022-01-31 11:00:00,513] [20] [INFO] No event to publish found
mobilizon-reshare_1  | [2022-01-31 11:00:00,514] [20] [INFO] Tortoise-ORM shutdown
mobilizon-reshare_1  | [2022-01-31 11:00:00,514] [20] [INFO] Job "partial (trigger: cron[day_of_week='mon-fri', hour='10-18', minute='*/15'], next run at: 2022-01-31 11:15:00 CET)" executed 
successfully

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions