-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Version:
- listmonk: [v3.0.0]
- OS: [Ubuntu LTS]
Description of the bug:
We are encountering an issue where the campaign status is marked as "finished" before all emails have been sent.
Campaign Details
- Campaign Type: Email
- Subscriber List: Single opt-in list with 200,000 subscribers
- Blocklisted Subscribers: Approximately 20,000
- Batch Size: 200
- Issue Observed: Campaign status changed to "finished" after sending only 37 emails
Analysis and Findings
Upon further investigation, we identified a potential bug in the query/code that might be causing this issue. Below are the details (Code Snippet from Pipe.go):
// NextSubscribers processes the next batch of subscribers in a given campaign.
// It returns a bool indicating whether any subscribers were processed
// in the current batch or not. A false indicates that all subscribers
// have been processed, or that a campaign has been paused or cancelled.
Campaign Scheduling Mechanism
The campaign scheduling mechanism uses last_subscriber_id
and max_subscriber_id
to process subscribers
in batches. The last_subscriber_id
acts as a pointer until max_subscriber_id
is reached.
The subIDs
query fetches distinct subscriber IDs and their subscription status from subscriber_lists
where the list
ID is among the lists from campLists
. Additionally, it filters out subscribers with the status unsubscribed.
If all subscribers that meet the criteria in subIDs
are blocklisted
, the subs CTE will return zero records due to the condition that excludes blocklisted subscribers.
Observed Behaviour in Our Case
In our scenario, during the second iteration, all 200 records were blocklisted, resulting in zero records being returned.
Consequently, the NextSubscribers
process returned false, causing the campaign status to be changed to "finished" without sending emails to the entire list.
Relevant Code in Pipe.go
// Line 85
if len(subs) == 0 {
return false, nil
}
Conclusion
The issue stems from the query filtering out blocklisted subscribers and returning zero records if all remaining subscribers in a batch are blocklisted. This causes the NextSubscribers
process to return false prematurely, changing the campaign status to "finished".
Recommendations
To address this issue, we recommend modifying the query and/or logic to ensure that the campaign does not prematurely
finish when encountering batches of blocklisted
subscribers. This will ensure that emails are sent to all eligible subscribers in the list.