SwiftQueue
SwiftQueue copied to clipboard
Last persisted job appears to run twice (before and after app restart)
👋
I'm having a problem with duplicate job runs after app startup when the job is persisted:
Repro: https://gist.github.com/ruslandoga/425765b892605c426f55b7c02683bace
Version: SwiftQueue (5.0.2)
Expected output:
job created Optional(["id": 4])
job runs Optional(["id": 4])
job removed Optional(["id": 4])
// -- app stops and then starts again --
job created Optional(["id": 5])
job runs Optional(["id": 5])
job removed Optional(["id": 5])
Actual output:
job created Optional(["id": "4"])
job runs Optional(["id": "4"])
job created Optional(["id": 4])
job created Optional(["id": "5"])
job runs Optional(["id": 4])
job runs Optional(["id": "5"])
job removed Optional(["id": 4])
job removed Optional(["id": "5"])
It seems to happen due to the last job being removed only after app restart.
This can be verified by first running jobs with ids 1, 2, then with 3, 4. Job 2 is present in both executions.
I know that i'ts already more than two years, but I have exact same problem. Job is added to queue and i'ts finished, but when I restart the app, there is exactly same job in queue again. Is there any way how to fix it?
Was the job removed from the data store that persist the job ? Only problem I could see is when the job is completed it's not successfully removed from the persister so the next time you launch the app it will create it and run it again.
Can you confirm ?
If I am undrstand it correctly, job should should automaticly removed from the persister after is finished? Because I think this the problem, job is not removed from persister.
@DEV1ANT7 Any reason why it's not removed ? Are you using the default persister ?