SMFHacks.com

SMF Store => Support => Topic started by: shuban on August 23, 2017, 02:18:02 pm

Title: [Urgent] What happens to CheckGroupExpire if index.php gets hit hard per second
Post by: shuban on August 23, 2017, 02:18:02 pm
In CheckGroupExpire, I have changed it in such a way so it charges members who are set to subscription via Stripe. Once it charges them, their time stamp in group_log time increases so they're not deleted from their membergroup.

However, I'm finding that sometimes the same member gets charged 4,5,6 times in one shot -- very bad! My question is, could index.php have something to do with it? Since the website it accessed many times per second, the function gets activated before it realizes that the time has been changed by updateSettings.

Is that a possiblity? And, if that's the case, could I start using cron jobs so that I activates the function precisely once every 30 minutes?

Title: Re: [Urgent] What happens to CheckGroupExpire if index.php gets hit hard per second
Post by: SMFHacks on August 23, 2017, 03:00:52 pm
I wouldn't put in the index.php. I would put inside another script then call that script via a cron job. Maybe once a minute or so
Title: Re: [Urgent] What happens to CheckGroupExpire if index.php gets hit hard per second
Post by: shuban on August 23, 2017, 03:13:08 pm
I created a cron instead. So you're telling me this is probably was the cause?
Title: Re: [Urgent] What happens to CheckGroupExpire if index.php gets hit hard per second
Post by: SMFHacks on August 23, 2017, 03:15:48 pm
Yes could be a race condition if you have many people hit the same page at one time the code gets executed multiple times until the condition is no longer valid.
Title: Re: [Urgent] What happens to CheckGroupExpire if index.php gets hit hard per second
Post by: shuban on August 23, 2017, 04:40:16 pm
Yes could be a race condition if you have many people hit the same page at one time the code gets executed multiple times until the condition is no longer valid.

Thanks bro