Quantcast
Channel: Backup and restore
Viewing all articles
Browse latest Browse all 6511

Custom backup code has trouble with File Cache

$
0
0
by Ray Hernandez.  

My environment:

Mac OS X Mavericks
Zend Server 6.1.0(PHP 5.4)
Postgres 9.3

So I've made a custom module for Moodle that required me to write backup and restore code. The backup and restore for this module is (as far as I can tell) fairly simple. I've followed the information here:

http://docs.moodle.org/dev/Backup_2.0_for_developers

If I perform a course backup everything works fine so long as I do not anonymize user data. If I do choose to anonymise user data, the backup fails with the following error:

Notice: unserialize(): Error at offset 336 of 2922 bytes in /Users/ray/Code/moodle/cache/classes/loaders.php on line 544

Notice: unserialize(): Error at offset 21 of 154 bytes in /Users/ray/Code/moodle/cache/classes/loaders.php on line 544

Notice: unserialize(): Error at offset 20 of 147 bytes in /Users/ray/Code/moodle/cache/classes/loaders.php on line 544
Coding error detected, it must be fixed by a programmer: Failed to unserialise data from file. Either failed to read, or failed to write.

More information about this error

Debug info:
Error code: codingerror
Stack trace:
line 469 of /cache/stores/file/lib.php: coding_exception thrown
line 372 of /cache/stores/file/lib.php: call to cachestore_file->prep_data_after_read()
line 299 of /cache/classes/loaders.php: call to cachestore_file->get()
line 1454 of /cache/classes/loaders.php: call to cache->get()
line 390 of /lib/dml/pgsql_native_moodle_database.php: call to cache_application->get()
line 582 of /lib/dml/moodle_database.php: call to pgsql_native_moodle_database->get_columns()
line 1688 of /lib/dml/moodle_database.php: call to moodle_database->where_clause()
line 101 of /backup/util/dbops/backup_structure_dbops.class.php: call to moodle_database->record_exists()
line 58 of /backup/util/structure/backup_final_element.class.php: call to backup_structure_dbops::insert_backup_ids_record()
line 115 of /backup/util/structure/backup_structure_processor.class.php: call to backup_final_element->annotate()
line 38 of /backup/util/structure/backup_final_element.class.php: call to backup_structure_processor->process_final_element()
line 97 of /backup/util/structure/backup_nested_element.class.php: call to backup_final_element->process()
line 107 of /backup/util/structure/backup_nested_element.class.php: call to backup_nested_element->process()
line 107 of /backup/util/structure/backup_nested_element.class.php: call to backup_nested_element->process()
line 107 of /backup/util/structure/backup_nested_element.class.php: call to backup_nested_element->process()
line 107 of /backup/util/structure/backup_nested_element.class.php: call to backup_nested_element->process()
line 97 of /backup/util/plan/backup_structure_step.class.php: call to backup_nested_element->process()
line 181 of /backup/util/plan/base_task.class.php: call to backup_structure_step->execute()
line 177 of /backup/util/plan/base_plan.class.php: call to base_task->execute()
line 120 of /backup/util/plan/backup_plan.class.php: call to base_plan->execute()
line 320 of /backup/controller/backup_controller.class.php: call to backup_plan->execute()
line 111 of /backup/util/ui/backup_ui.class.php: call to backup_controller->execute_plan()
line 131 of /backup/backup.php: call to backup_ui->execute()


This only happens if I am using the file cache. If I switch to Memcache or MongoDB the backup works fine. The problem seems to be happening when the get_columns() function is called in the lib/dml/pgsql_native_moodle_database.php file around line 386:

$cache = cache::make('core', 'databasemeta', $properties);
if ($data = $cache->get($table)) {
return $data;
}

The $table variable is set to 'backup_ids_temp'. The "$cache->get($table)" eventually blows up in cache/stores/file/lib.php around line 372. There is a call:

return $this->prep_data_after_read($data);

But the $data var is NULL so the unserialize function throws an exception.

I'm not sure if this is a bug or if I am doing something wrong. Has anyone seen this before? Any clues as to where I might look?

 

Thanks in advance for any clues you might be able to offer,

--Ray


Viewing all articles
Browse latest Browse all 6511

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>