SwiftQueue icon indicating copy to clipboard operation
SwiftQueue copied to clipboard

Last persisted job appears to run twice (before and after app restart)

Open ruslandoga opened this issue 3 years ago • 5 comments

👋

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"])

ruslandoga avatar Jan 31 '21 12:01 ruslandoga

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.

ruslandoga avatar Jan 31 '21 12:01 ruslandoga

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?

DEV1ANT7 avatar Apr 21 '23 08:04 DEV1ANT7

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 ?

lucas34 avatar Apr 21 '23 08:04 lucas34

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 avatar Apr 21 '23 09:04 DEV1ANT7

@DEV1ANT7 Any reason why it's not removed ? Are you using the default persister ?

lucas34 avatar Apr 22 '23 06:04 lucas34