Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ruslandoga opened this issue Jan 31, 2021 · 5 comments
Open

Comments

@ruslandoga
Copy link

ruslandoga commented Jan 31, 2021

👋

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
Copy link
Author

ruslandoga commented Jan 31, 2021

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 ruslandoga changed the title Persisted job appears to run twice. Persisted job appears to run twice after app restart Jan 31, 2021
@ruslandoga ruslandoga changed the title Persisted job appears to run twice after app restart Last persisted job appears to run twice (before and after app restart) Jan 31, 2021
@davidsoukup
Copy link

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?

@lucas34
Copy link
Owner

lucas34 commented Apr 21, 2023

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 ?

@davidsoukup
Copy link

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.

@lucas34
Copy link
Owner

lucas34 commented Apr 22, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants