Can't find data record in database table context.

Can't find data record in database table context.

by Nelson Homer Talag -
Number of replies: 4

Hi all,

i recently micgated my moodle from 3.5 to 3.9

plugins and database upgrade was successful

however when i logged in i get an error on my dashboard page

all admin pages seems to be working when i hard navigate to the site admin url

i turned on my debug mode and here are the stack trace i got


Debug info: SELECT * FROM {context} WHERE id = ?
[array (
0 => '505853',
)]
Error code: invalidrecord
Stack trace:
  • line 1599 of /lib/dml/moodle_database.php: dml_missing_record_exception thrown
  • line 1575 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select()
  • line 5289 of /lib/accesslib.php: call to moodle_database->get_record()
  • line 5678 of /lib/accesslib.php: call to context::instance_by_id()
  • line 5531 of /lib/accesslib.php: call to context->get_parent_context()
  • line 5106 of /lib/accesslib.php: call to context->is_locked()
  • line 2711 of /course/classes/category.php: call to context->__get()
  • line 72 of /cache/lib.php: call to core_course_category->prepare_to_cache()
  • line 744 of /cache/classes/loaders.php: call to cache_cached_object->__construct()
  • line 398 of /course/classes/category.php: call to cache->set_many()
  • line 1219 of /calendar/lib.php: call to core_course_category::get_all()
  • line 1121 of /calendar/lib.php: call to calendar_information->set_sources()
  • line 54 of /blocks/calendar_month/block_calendar_month.php: call to calendar_information::create()
  • line 341 of /blocks/moodleblock.class.php: call to block_calendar_month->get_content()
  • line 235 of /blocks/moodleblock.class.php: call to block_base->formatted_contents()
  • line 1181 of /lib/blocklib.php: call to block_base->get_content_for_output()
  • line 1233 of /lib/blocklib.php: call to block_manager->create_block_contents()
  • line 374 of /lib/blocklib.php: call to block_manager->ensure_content_created()
  • line 3966 of /lib/outputrenderers.php: call to block_manager->region_has_content()
  • line 40 of /theme/moove/layout/mydashboard.php: call to core_renderer->blocks()
  • line 1374 of /lib/outputrenderers.php: call to include()
  • line 1304 of /lib/outputrenderers.php: call to core_renderer->render_page_layout()
  • line 164 of /my/index.php: call to core_renderer->header()
i queried the database and the record is indeed missing

however i dont know what to do to fix this issues

thanks in advance for any help



Average of ratings: -
In reply to Nelson Homer Talag

Re: Can't find data record in database table context.

by Ken Task -
Picture of Particularly helpful Moodlers

There is a table called 'mdl_context_temp'.   What does:

select * from mdl_context_temp;

show?

Temp tables normally don't have anything in them after they are used for whatever purpose.

Wonder what would happen if you truncated that temp table:

mysql> truncate mdl_context_temp;

Before you do, backup (mysqldump) your database.

'SoS', Ken


In reply to Ken Task

Re: Can't find data record in database table context.

by Nelson Homer Talag -

Thanks ken,

the query showed no record also

however this has been resolved and this is the article that helped

https://docs.moodle.org/39/en/How_to_rebuild_context_paths

thanks for the help :D

Average of ratings: Useful (3)
In reply to Nelson Homer Talag

Re: Can't find data record in database table context.

by Ken Task -
Picture of Particularly helpful Moodlers

Have never seen that page ... hmmmmm ... maybe at end of stack trace or when error is thrown a link to 'more info about this error' should point to that page.

Yep ... I forgot to look at cli task. :|

As long as all is well! smile

'SoS', Ken

In reply to Nelson Homer Talag

Re: Can't find data record in database table context.

by Zdeněk Válek -
Attached SQL code will help you check for bad contextual paths for courses (attached as file).

SQL for check course context paths (for MariaDB 10.2.2)
This code require supporting WITH statements and granted SUPER privilege for creating db function
Table mdl_course_index_contexts contain course context paths with error flag and new correct path

Average of ratings: Useful (1)