My PHP version is : 7.4.13
My MySQL/MariaDB version is (delete as applicable): MySQL 5.7
My problem is :
I have two contacts getting added into the same segments at different times, even when they are added through API at the same time? I wonder if anyone has faced a similar issue.
Steps I have tried to fix the problem :
Couldn’t address the cause of this issue.
you have to look at very aspect of your configuration (task schedules, campaigns and segments)
there are different ways a contact can be added or removed from a segment. if a segment have filters, there is a background routine that updates the segment membership that runs on the server every now and then (schedule is configured at each server but I think the default is every 15 minutes, not sure). but if you add the contact manually, the filter will not remove the contact. segments membership can add the contact to a campaign and a campaign have the power to add or remove contacts from segments, and the actions of the campaign also runs as background tasks on the server.
so you might have a scenario where you add a contact to a segment, the segment triggers a campaign, the campaign changes the segments of the contact.
also some condition on the segment filter depends on data that is also being calculated during the background tasks, which may delay the inclusion of the contact on a segment.
it is really hard to detect what is causing the issue without knowing your specific scenario and config.
perhaps a look on the log may show that some routines are being interrupted by an error.
if you already using the api to create a contact, I suggest you use the same api to add the contact to a segment, instead of depend on the segment update task
Your explanation is really clear and helpful. I will give it a try with your suggestion.