moodle 3.8 Table "sessions" does not exist Error code: ddltablenotexist

moodle 3.8 Table "sessions" does not exist Error code: ddltablenotexist

door Serge Karayan -
Aantal antwoorden: 14
Wishing you all a Happy Healthy 2024

Since coming back our Moodle 3.8 came up with an issue with the Add an activity or resource is greyed out. I checked all permissions and nothing has been changed

in the Server environment I can see only one error 
mysql_full_unicode_support

The current setup of MySQL or MariaDB is using 'utf8'. This character set does not support four byte characters which include some emoji. Trying to use these characters will result in an error when updating a record, and any information being sent to the database will be lost. Please consider changing your settings to 'utf8mb4'. See the documentation for full details.



Before upgrading or tampering with our main Moodle platform to make sure I have copied files over to a new server with SSL and a new host domain changed the domain references in the database and config.php imported the database.

to get this test platform working I had to use PHP 7.2

Now I get the error

Table "sessions" does not exist
Debug info:
Error code: ddltablenotexist
Stack trace:
  • line 665 of /lib/dml/moodle_database.php: dml_exception thrown
  • line 1537 of /lib/dml/moodle_database.php: call to moodle_database->where_clause()
  • line 327 of /lib/classes/session/manager.php: call to moodle_database->get_record()
  • line 98 of /lib/classes/session/manager.php: call to core\session\manager::initialise_user_session()
  • line 793 of /lib/setup.php: call to core\session\manager::start()
  • line 32 of /config.php: call to require_once()
  • line 30 of /index.php: call to require_once()
With great Humilty any Help will be greatly appreciated


Gemiddelde van de beoordelingen:  -
Als antwoord op Serge Karayan

Re: moodle 3.8 Table "sessions" does not exist Error code: ddltablenotexist

door Serge Karayan -
if I change this in config.php

from this

require_once(__DIR__ . '/lib/setup.php');

to this

require_once(__DIR__ . '/course/lib.php');

I get no errors just a blank white screen

if I comment out //require_once(__DIR__ . '/lib/setup.php');

I get this error

Notice: Undefined property: stdClass::$dirroot in /web/index.php on line 31

Warning: require_once(/course/lib.php): failed to open stream: No such file or directory in /web/index.php on line 31

Fatal error: require_once(): Failed opening required '/course/lib.php' (include_path='.:/usr/share/php') in /web/index.php on line 31
Gemiddelde van de beoordelingen:  -
Als antwoord op Serge Karayan

Re: moodle 3.8 Table "sessions" does not exist Error code: ddltablenotexist

door Ken Task -
Foto van Particularly helpful Moodlers
Revert whatever change you have made to config.php and instead tell your moodle to use files for sessions rather than database by adding a line to config.php:

$CFG->dbsessions='0';

That should force moodle to create a sessions directory in moodledata/ and session files will be created there.   Does take stress off your DB.

'SoS', Ken



Gemiddelde van de beoordelingen:  -
Als antwoord op Serge Karayan

Re: moodle 3.8 Table "sessions" does not exist Error code: ddltablenotexist

door Ken Task -
Foto van Particularly helpful Moodlers
In your 3.8 code admin/cli/ there are php scripts that will help with DB compliance to utf8mb4 character set and collation.

mysql_engine.php, mysql_collation.php, and mysql_compressed_rows.php

They all have help if issued without parameters.

Reason to use them: they loop through all tables and columns in those tables.

On your new server environment defaults now for MySQL/MariaDB are to use utf8mb4.

In doing server migrations have always found it best to get code to the highest posssible and fix what needs to be fixed as much as possible *before* moving to the new environment.   That's if possible, of course.

'SoS', Ken

Gemiddelde van de beoordelingen:  -
Als antwoord op Ken Task

Re: moodle 3.8 Table "sessions" does not exist Error code: ddltablenotexist

door Serge Karayan -
Thank you Ken

After editing the config file

with adding your suggestion

$CFG->admin     = 'admin';
$CFG->dbsessions='0';
$CFG->directorypermissions = 0777;


@error_reporting(E_ALL | E_STRICT);
@ini_set('display_errors', '1');
$CFG->debug = (E_ALL | E_STRICT);
$CFG->debugdisplay = 1;

require_once(__DIR__ . '/lib/setup.php');

// There is no php closing tag in this file,
// it is intentional because it prevents trailing whitespace problems!

I get this new error

Field "sid" does not exist in table "sessions"
Debug info:
Error code: ddlfieldnotexist
Stack trace:
  • line 672 of /lib/dml/moodle_database.php: dml_exception thrown
  • line 1537 of /lib/dml/moodle_database.php: call to moodle_database->where_clause()
  • line 327 of /lib/classes/session/manager.php: call to moodle_database->get_record()
  • line 98 of /lib/classes/session/manager.php: call to core\session\manager::initialise_user_session()
  • line 793 of /lib/setup.php: call to core\session\manager::start()
  • line 33 of /config.php: call to require_once()
  • line 30 of /index.php: call to require_once()
on Checking the field is in the database to make sure its there it is

SID
Gemiddelde van de beoordelingen:  -
Als antwoord op Serge Karayan

Re: moodle 3.8 Table "sessions" does not exist Error code: ddltablenotexist

door Ken Task -
Foto van Particularly helpful Moodlers
Well that's 'special' ... shouldn't be trying to talk DB for sessions.

Did your moodle create  a sessions directory in moodledata?
If not, create one manually and give it same ownerships/permissions as other directories in moodledata.

Are files being created in there now and error gone away?
If not ....
truncate the sessions table ... ie, leave table and columns there, just remove all the data in that table.

May have to beat it into submission! :|

'SoS', Ken

Gemiddelde van de beoordelingen:  -
Als antwoord op Ken Task

Re: moodle 3.8 Table "sessions" does not exist Error code: ddltablenotexist

door Serge Karayan -
Hi Ken

Yes its created the sessions folder as you can see here
sessions folder

and I've emptied the sessions table of all data

Sessions table
But I'm still getting this error I've restarted apache and mariadb just in case
error


Gemiddelde van de beoordelingen:  -
Als antwoord op Serge Karayan

Re: moodle 3.8 Table "sessions" does not exist Error code: ddltablenotexist

door Ken Task -
Foto van Particularly helpful Moodlers
I see webclient1 as user.   Is that the user your web server runs under?

I see mode 0600.   Is that the same as ugo+rwx sessions -R
ls -ld sessions
drwxrwsrwx. 2 apache apache 4096 Jan  5 03:26 sessions

and the first column of your screen shot ... not sure what it shows, but
session files look like this on every server I admin:

-rw-------. 1 apache apache 6694 Jan  5 11:56 sess_07cca958e322c8fd5cbd944cee9899e8

mysql> explain mdl_sessions;
+--------------+--------------+------+-----+---------+----------------+
| Field        | Type         | Null | Key | Default | Extra          |
+--------------+--------------+------+-----+---------+----------------+
| id           | bigint(10)   | NO   | PRI | NULL    | auto_increment |
| state        | bigint(10)   | NO   | MUL | 0       |                |
| sid          | varchar(128) | NO   | UNI |         |                |
| userid       | bigint(10)   | NO   | MUL | NULL    |                |
| sessdata     | longtext     | YES  |     | NULL    |                |
| timecreated  | bigint(10)   | NO   | MUL | NULL    |                |
| timemodified | bigint(10)   | NO   | MUL | NULL    |                |
| firstip      | varchar(45)  | YES  |     | NULL    |                |
| lastip       | varchar(45)  | YES  |     | NULL    |                |
+--------------+--------------+------+-----+---------+----------------+
9 rows in set (0.00 sec)

Hmmm ... just looked:

 mysql> select id,state,sid,userid from mdl_sessions;
+----+-------+----------------------------------+--------+
| id | state | sid                              | userid |
+----+-------+----------------------------------+--------+
| 18 |     0 | 07cca958e322c8fd5cbd944cee9899e8 |      4 |
+----+-------+----------------------------------+--------+
1 row in set (0.00 sec)

If you note the file above that begins with sess_ then that number.
That number is the same as the 'sid' column data.

Is your DB user in config.php: webclient1?

Have you run those other scripts in code/admin/cli/ that pertain to character set/collation?
IF not, do that! glimlach

'SoS', Ken


Gemiddelde van de beoordelingen:  -
Als antwoord op Ken Task

Re: moodle 3.8 Table "sessions" does not exist Error code: ddltablenotexist

door Serge Karayan -
Hi Ken,

The server is a Lamp Debian running ISPconfig

its one of my servers so I'm the root

permissions for that directory is 777
perm

I did try to run from ssh in sudo user in the admin/cli directory


I get this
ssh

should I edit the config.php to reflect just utf8mb4 without the unicode_ci before I stop the server and then run the

sudo -u www-data /usr/bin/php mysql_collation.php --collation=utf8mb4

do you think an upgrade would do it all or should I go step by step as when I do get past this copy server running will try the upgrade anyway to get to at least the closest I can to the latest version with the plugins and themes we have. if I get this working to the latest version I'll just make the main server the backup and redirect everyone to use this.

Really greatly appreciate your expertise and support and time.


Gemiddelde van de beoordelingen:  -
Als antwoord op Serge Karayan

Re: moodle 3.8 Table "sessions" does not exist Error code: ddltablenotexist

door Ken Task -
Foto van Particularly helpful Moodlers
If this server is in maintenance mode .. I assume it is ... getting prep'd to migrate so good idea to keep all users out.

As root user ok:
php admin/cli/maintenance.php --enable
Cron will not run in that mode.   So before the archive of the site,
php admin/cli/maintenance.php --disable
then
php admin/cli/cron.php
Might do that last command until no jobs.

If you are already in as 'root', no reason to sudo to root!   Matter of fact, when I get onto a system that uses sudo, I find it gets in the way and use sudo -s then provide password for the account I logged on as to stay root and never have to use sudo.
I do have to use exit command twice ... once to get out of sudo and once more to log out.

The only reason to use sudo as web service user is when file/folder ownerships would change if using script as root.   In this case, you are not changing files, but working with the DB, it's tables, and columns in those tables.

If you are already in code root and issuing the db conversion script it shouldn't take long.   And since you are right there where config.php is located nano config.php and making changes to DB lines doesn't take very long at all.   Besides, you need to take the site
out of the maintenance mode so you can check the site via GUI now and do other stuff like check and get the additional plugins.

Upgrading won't fix the DB issue stuff I don't think ... do know that upgrading to 4.x you will loose the cli script for engine in admin/cli ... so as long as you have it available now use it.

i'll repeat ... get as much fixed correctly as you can prior to migration.   Get as high a version of Moodle as you can before mirgation - and know that there are no issues at that version.

Upgrading and migrating at the same time could be problematic.

When finally pulling trigger on migration, all you have to do is archive (backup the site - code + DB dump + minimal moodledata/filedir) the site, xfer the backups to the new hosting, unarchive and place in proper locations, import DB dump into new DB.   Change config.php to new DB name, login, and password.

Check ownerships/permissions on all files/folders in code and moodledata.   Make sure config.php file is readable by the globe.

'SoS', Ken
 

Gemiddelde van de beoordelingen: Useful (1)
Als antwoord op Serge Karayan

Re: moodle 3.8 Table "sessions" does not exist Error code: ddltablenotexist

door Serge Karayan -
Done all working thank you all I had to do was run the from admin/cli purge_caches.php glimlach
Gemiddelde van de beoordelingen:  -
Als antwoord op Serge Karayan

Re: moodle 3.8 Table "sessions" does not exist Error code: ddltablenotexist

door Ken Task -
Foto van Particularly helpful Moodlers
Yep!  That was next on the list of things to do ...
now for the migration! glimlach

'SoS', Ken

Gemiddelde van de beoordelingen:  -
Als antwoord op Serge Karayan

Re: moodle 3.8 Table "sessions" does not exist Error code: ddltablenotexist

door Serge Karayan -
sorry ken
I've updated the database collation it's now utf8mb4_unicode_ci

Now I'm finding missing menus in the courses its the plugin collapsable topics when I try to update the plugins it gives me this

Error writing to database

More information about this error
Debug info: Field 'id' doesn't have a default value
INSERT INTO soft_config (name,value) VALUES(?,?)
[array (
0 => 'upgraderunning',
1 => 1704497765,
)]
Error code: dmlwriteexception
Stack trace:

line 489 of /lib/dml/moodle_database.php: dml_write_exception thrown
line 1331 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
line 1377 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
line 1406 of /lib/moodlelib.php: call to mysqli_native_moodle_database->insert_record()
line 1506 of /lib/upgradelib.php: call to set_config()
line 1587 of /lib/upgradelib.php: call to upgrade_started()
line 821 of /lib/upgradelib.php: call to print_upgrade_part_start()
line 532 of /lib/upgradelib.php: call to upgrade_plugins_modules()
line 1877 of /lib/upgradelib.php: call to upgrade_plugins()
line 694 of /admin/index.php: call to upgrade_noncore()


if I try to upload the zip file manually

Error
Can not create file "5154/user/draft/804791415/format_collapsibletopics_moodle39.zip"
URL: https://ommited/
Debug info: Field 'id' doesn't have a default value INSERT INTO soft_files (contextid,component,filearea,itemid,filepath,filename,timecreated,timemodified,mimetype,userid,source,author,license,status,sortorder,contenthash,filesize,pathnamehash) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) [array ( 0 => 5154, 1 => 'user', 2 => 'draft', 3 => 804791415, 4 => '/', 5 => 'format_collapsibletopics_moodle39.zip', 6 => 1704497911, 7 => 1704497911, 8 => 'application/zip', 9 => '806', 10 => 'O:8:"stdClass":1:{s:6:"source";s:48:"format_collapsibletopics_moodle39_2020061700.zip";}', 11 => 'Serge Karayan', 12 => 'allrightsreserved', 13 => 0, 14 => 0, 15 => 'da4dc6a79fb4ce2a76f8957b5d2cb04ef6002bfa', 16 => 51922, 17 => '36170aac3f506a3db44c5f2f7f2a7eab6df68b59', )] Error code: storedfilenotcreated
Stack trace:

* line 1333 of /lib/filestorage/file_storage.php: stored_file_creation_exception thrown
* line 229 of /repository/upload/lib.php: call to file_storage->create_file_from_pathname()
* line 63 of /repository/upload/lib.php: call to repository_upload->process_upload()
* line 324 of /repository/repository_ajax.php: call to
Gemiddelde van de beoordelingen:  -
Als antwoord op Serge Karayan

Re: moodle 3.8 Table "sessions" does not exist Error code: ddltablenotexist

door Ken Task -
Foto van Particularly helpful Moodlers
So what version are we currently still - 3.8?

Moodle admin doesn't have a GUI plugins checker.

Please see;
https://docs.moodle.org/403/en/Installing_plugins
In the outline designations - section 4.2 or 4.3
Even though the link above shows 403 the info at section 4.2 or 4.3 should still apply.

You aren't using git to update/upgrade core so using old method.
You should have an old moodle directory that you created to make space for the new 3.9 code.   In that old moodle directory, course -> format there should be a 'topcoll' directory.
copy that directory to new code in course/format/

To manually upgrade collapse topics format:

Acquire the URL to the version of the plugin you need:
search
when you find the plugin the first page of that plugin will show the latest version.
We don't want that one.   Click version tab.   Find your version needed.
Right Click or CTRL Click the 'download' button.
Copy that URL and paste  to a local text file - NotePad/TextEdit

cd path/to/code/course/format/
mv topcoll .topcoll (note there a dot in front of the second directory
That hides it from moodle and allows you to acquire new:


wget versionurlabove (paste the  URL from your local text document.

unzip format*.zip

Then go to php admin/cli/upgrade.php --non-interactive and collapsed topics will be upgraded.

Repeat the process for every plugin you have only those will probably go into different directories.


'SoS', Ken


Gemiddelde van de beoordelingen:  -
Als antwoord op Ken Task

Re: moodle 3.8 Table "sessions" does not exist Error code: ddltablenotexist

door Serge Karayan -
my copy server is still 3.8
not using git at the moment for this
I've downloaded the plugins format_collapsibletopics_moodle39_2020061700 and the topcoll format_topcoll_moodle38_2019111707

on /var/www/clients/client1/web20/web/admin/cli#
when I run

/usr/bin/php upgrade.php
No upgrade needed for the installed version 3.8 (Build: 20191118) (2019111800). Thanks for coming anyway!

/usr/bin/php upgrade.php --none-interactive
Unrecognised options:
--none-interactive

oh by the way I can see the topics menu now in the course but when I try to Add an activity or resource

ie even raised the database user permissions thinking because of the error cant write to the database but to no avail still getting

on any upload or plugin installation from the GUI

https://docs.moodle.org/38/en/error/moodle/dmlwriteexception

link

link2

pl
pl2
pl3

it keeps bringing up this coding error

I really greatly appreciate all your support is there a way I can pay you or someone to fix this please let me know as I'm on a deadline to get this running by Monday if so please let me know either way.

and when your in a course and try to edit settings gives this error

settings

Gemiddelde van de beoordelingen:  -