Clear Old Session query block each other.

Clear Old Session query block each other.

by vikas patel -
Number of replies: 3

Hello,

We are using Moodle 3.7 with PHP 7 and MS SQL.We did not any customization Moodle Code.

Query block each other when Clear old session task run in Moodle Corn.,See below Two query which block each other.

SELECT u.*, s.sid, s.timecreated AS s_timecreated, s.timemodified AS s_timemodified
                      FROM mdl_user u 
                      JOIN mdl_sessions s  ON s.userid = u.id
                     WHERE s.timemodified < '1562738746' AND u.id <> '1'

                    
                    
DELETE [mdl_sessions]  WHERE [sid]=@1

Is this modle Default BUG!!!!.

Please help us solve Issue,


Average of ratings: -
In reply to vikas patel

Re: Clear Old Session query block each other.

by Andreas Grabs -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers Picture of Translators
Hi,
I don't know how many sessions you want to kill. But maybe the API call is more suitable for you:
\core\session\manager::kill_session($sid);
This will work for all handlers not only running on database.

Best regards
Andreas
In reply to Andreas Grabs

Re: Clear Old Session query block each other.

by vikas patel -
Thanks For Replay,
We don't want to kill sessions. Problem is that select and delete SQL query block each other means select query required data which delete query can delete so, both SQL query block each other like deadlock.
This both SQL Query written in clear session corn task. When cron was run this Two SQL Query Make Blockage In Database.