mirror of
https://github.com/ushahidi/SMSSync.git
synced 2026-04-25 07:45:53 +03:00
[GH-ISSUE #454] Race condition in publishing can cause messages to be published multiple times #317
Labels
No labels
Bug report
Code improvement
Concern
Feature request
Feature request
Good first issue to work on
In progress
Needs info
Question
Ready
Translation
User Experience
User Experience
Website
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/SMSSync#317
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @vanso-hubsi on GitHub (Jun 29, 2016).
Original GitHub issue: https://github.com/ushahidi/SMSSync/issues/454
Expected behavior
Each message gets only published once, no matter what.
Actual behavior
With messages waiting in Incoming, each press on the publish icon seems to start a publishing thread, even if it is already running.
When there's an issue with the internet or the receiving web service, that makes requests from SMSSync time out, each publishing request takes 30 seconds to time out, making the publishing thread take a long time.
Say you have 20 messages in Incoming due to connection issues and you press the publish button, those 20 messages are picked by a new publishing thread and each attempt to deliver takes 30 seconds.
If you press the publish button again after one minute (thinking it didn't work), another publishing thread is started in parallel, trying to submit the very same messages again.
If the connection starts working again while those threads are still running, the remaining messages in both tasks get sent to the server, resulting in messages being delivered twice.
And if the auto sync job stepped in, they'd even be delivered three times.
The same happens if you accidently hit the publish button multiple times.
Steps to reproduce the behavior
see above
Notes
I hope my analysis is correct. If so, the following solutions I'd like to suggest come to my mind:
@gnguyo commented on GitHub (Jul 8, 2016):
Any fix for this yet?
@levimatheri commented on GitHub (Aug 10, 2016):
I'd suggest using a thread pool where a thread is only called if it needs to be used.