Upgrading moodle - dmlwriteexception error

Upgrading moodle - dmlwriteexception error

by Walter J -
Number of replies: 2

Hi, 

we are running moodle 2.4 on a debian 9 server with postgreSQL 9.6.15 and php 5.6.33. Everything seems to be working right, but when I try to upgrade to 2.7 before going into the 3.x releases using this post: https://docs.moodle.org/27/en/Upgrading we got the dmlwriteexception error with this messages on error log:

[Tue Sep 03 16:16:35.147011 2019] [:error] [pid 4923] [client xx.xx.xx.xx:5129] Default exception handler: Error writing to database Debug: ERROR:  permission denied for sequence mdl_config_id_seq\nINSERT INTO mdl_config (name,value) VALUES($1,$2) \n[array (\n  'name' => 'localcachedirpurged',\n  'value' => 1567538195,\n)]\nError code: dmlwriteexception\n* line 446 of /lib/dml/moodle_database.php: dml_write_exception thrown\n* line 244 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end()\n* line 868 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()\n* line 924 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->insert_record_raw()\n* line 1375 of /lib/moodlelib.php: call to pgsql_native_moodle_database->insert_record()\n* line 1628 of /lib/moodlelib.php: call to set_config()\n* line 275 of /admin/index.php: call to purge_all_caches()\n
[Tue Sep 03 16:16:36.146301 2019] [:error] [pid 4925] [client xx.xx.xx.xx:5130] PHP Fatal error:  Call to undefined method theme_config::css_files() in /var/www/moodle/theme/styles.php on line 141, referer: http://xxx.xxx.xxx/admin/index.php

Any ideas?

Average of ratings: -
In reply to Walter J

Re: Upgrading moodle - dmlwriteexception error

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I'm not much of a Postgres user, but, Postgres 9.6 was released two years after Moodle 2.7 and the error you are getting seems to be a Postgres error. I would stick with the minimum recommended version for 2.7 (9.1) as you know for certain it has been fully tested with that.
In reply to Walter J

Re: Upgrading moodle - dmlwriteexception error

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

This is a permissions error being returned by PostgreSQL. You could try running the following statement in psql with when connected to the Moodle database (\c <moodle_dbname>):

GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA public TO <moodle_dbuser>;

where <moodle_dbuser> is the $CFG->dbname from config.php, i.e. the PostgreSQL user account Moodle is accessing the database as.

If this doesn't work you'll need to tell us more details about how you set up the database for the Moodle 2.7 site: is this on the same PostgreSQL instance as the 2.4 site or is it on a different server? If it's on a different server, what steps did you follow to copy the database? How exactly did you set up the PostgreSQL user for the Moodle 2.7 database?