Configurable Reports Plugin Error

Configurable Reports Plugin Error

by rupamoy bhattacharya -
Number of replies: 3

I'm using following query for configurable reports , but it is giving session timed out error as user count is more than 200 only. Have tried nolock but there is no as such effect of that.  Following is the query and also the error message. Any suggestion to optimize or get rid of the error.


Query :

SELECT DISTINCT CONCAT(u.FIRSTNAME, ' ', u.LASTNAME) AS NAME, campus_value_department_x.data AS 'department' , campus_value_occupation_x.data AS 'occupation'

, c.fullname AS 'Course',

CASE WHEN gi.itemtype = 'Course'   

THEN c.fullname + ' Course Total'  

ELSE gi.itemname

END AS 'Activity Name'

,ROUND(gg.finalgrade / gg.rawgrademax * 100 ,2) AS Percentage

,IF (ROUND(gg.finalgrade / gg.rawgrademax * 100 ,2) > 79,'Yes' , 'No') AS Pass

FROM  prefix_course c

,prefix_context ctx

,prefix_role_assignments ra

,prefix_user u

,prefix_grade_grades gg

,prefix_grade_items gi

,prefix_course_categories cc

,prefix_user_info_data ud

,(SELECT * FROM prefix_user_info_data WHERE fieldid=4 AND userid IN (SELECT userid FROM prefix_cohort_members WHERE cohortid=16)) campus_value_department_x

,(SELECT * FROM prefix_user_info_data WHERE fieldid=5 AND userid IN (SELECT userid FROM prefix_cohort_members WHERE cohortid=16)) campus_value_occupation_x

WHERE 1=1

AND   c.id = ctx.instanceid

AND   ra.contextid = ctx.id

AND   u.id = ra.userid

AND   gg.userid = u.id

AND   gi.id = gg.itemid

AND   cc.id = c.category

AND   campus_value_department_x.userid=u.id

AND   campus_value_occupation_x.userid=u.id

AND   gi.courseid = c.id

AND   gi.itemname != 'Attendance'

ORDER BY 'Name' ASC


Error :


Timed out while waiting for session lock.

Wait for your current requests to finish and try again later.

 

Debug info:

Error code: sessionwaiterr

Average of ratings: -
In reply to rupamoy bhattacharya

Re: Configurable Reports Plugin Error

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

It sounds like something else is keeping the database busy...you might try restarting the database server and see if that resolves it.

In reply to Emma Richardson

Re: Configurable Reports Plugin Error

by rupamoy bhattacharya -

Hello Emma,

Thanks for your reply smile .. I was wondering that rest of the DB operations except this query are working fine. So what may be the effect of restarting DB server which can resolve the issue. The reason I want to avoid DB server restart is because our Moodle site is in use by the students and we would like to resolve this issue as far as keeping the servers up and running. Can you please reply with your point of view and I will restart the DB server if that is the only solution.


Regards,

Rupamoy 

In reply to rupamoy bhattacharya

Re: Configurable Reports Plugin Error

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

I guess you could just try waiting but if the error continually appears, there are a couple of possibilities that I can think of - maybe someone else has some other insight - 

1.  Depending on the size of your database, this query, which appears fairly lengthy could well just be taking a long time to run.  During the run time, it is possible that maybe something else like cron is firing up and causing a conflict.

2.  Again, with a long query, it could be that it started to run this query once and something happened that caused the query to stall not allowing it to run again.

What I might try is to fire up phpmyadmin or adminer and try running the query there.  If it doesn't work there, try another simpler query.  If you keep getting errors, a server restart might be necessary - backup first!