file-list "-i" option gives PHP error
Hi,
if I use the "-i" option for file-list, i.e: "moosh file-list -i course=26 | moosh file-path -s -r | tar -C $(moosh config-get core dataroot) -T - -czf /home/admin/dateiablage.tgz" I get this PHP error: "Default exception handler: Fehler beim Schreiben der Datenbank Debug: Duplicate entry '' for key 'mdl_sess_sid_uix' INSERT INTO mdl_sessions (state,sid,sessdata,userid,timemodified,timecreated,lastip,firstip) VALUES(?,?,?,?,?,?,?,?) [array ( 0 => 0, 1 => '', 2 => NULL, 3 => '2', 4 => 1427271809, 5 => 1427271809, 6 => '0.0.0.0', 7 => '0.0.0.0', )] Error code: dmlwriteexception
- line 446 of /lib/dml/moodle_database.php: dml_write_exception thrown
- line 1164 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
- line 1210 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
- line 422 of /lib/classes/session/manager.php: call to mysqli_native_moodle_database->insert_record()
- line 464 of /lib/classes/session/manager.php: call to core\session\manager::add_session_record()
- line 4581 of /lib/moodlelib.php: call to core\session\manager::login_user()
- line 215 of /home/admin/moosh/moosh.php: call to complete_user_login()
tar: File '!!! Fehler beim Schreiben der Datenbank !!!' not found: Kann stat nicht ausführen: Datei oder Verzeichnis nicht gefunden tar: Beende mit Fehlerstatus aufgrund vorheriger Fehler " Without the "-i" option the tar file is created but not with the real files in it. Instead the relative path in moodledata are compressed, i.e "filedir/00/..."
What goes wrong here?
Thanks Andreas
Hi, I also encountered this issue using the command moosh file-list -i "component = 'assignfeedback_editpdf' and filesize > 1000000" | moosh file-delete -s
I did not encounter the issue when running just the file-list command, and I do not encounter it if I use the file-delete command using file IDs as arguments (ie, moosh file-delete 10 20 30). I also got the error when trying to combine the file-list command with file-path. My best guess is that this is only happening when using | to combine commands, presumably Moodle is expecting a new session for each command but Moosh is not clearing the previous session?
For the record, here's my error info:
Default exception handler: Error writing to database Debug: ERROR: duplicate key value violates unique constraint "mdl_sess_sid_uix"
DETAIL: Key (sid)=() already exists.
INSERT INTO mdl_sessions (state,sid,sessdata,userid,timemodified,timecreated,lastip,firstip) VALUES($1,$2,$3,$4,$5,$6,$7,$8) RETURNING id
[array (
'state' => 0,
'sid' => '',
'sessdata' => NULL,
'userid' => '2',
'timemodified' => 1635525791,
'timecreated' => 1635525791,
'lastip' => '0.0.0.0',
'firstip' => '0.0.0.0',
)]
Error code: dmlwriteexception
* line 489 of /lib/dml/moodle_database.php: dml_write_exception thrown
* line 329 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end()
* line 1025 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
* line 1073 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->insert_record_raw()
* line 540 of /lib/classes/session/manager.php: call to pgsql_native_moodle_database->insert_record()
* line 583 of /lib/classes/session/manager.php: call to core\session\manager::add_session_record()
* line 4693 of /lib/moodlelib.php: call to core\session\manager::login_user()
* line 306 of /var/www/moosh/moosh.php: call to complete_user_login()
any solution?
I know this is kind of an old issue, but I'm also running into this sporadically when calling
moosh -n file-list -a filename='backup.mbz' and timecreated>1642044646 | moosh -n file-delete -s
moosh -n file-delete --flush
Default exception handler: Error writing to database Debug: Duplicate entry '' for key 'mdl_sess_sid_uix'
INSERT INTO mdl_sessions (state,sid,sessdata,userid,timemodified,timecreated,lastip,firstip) VALUES(?,?,?,?,?,?,?,?)
[array (
0 => 0,
1 => '',
2 => NULL,
3 => '2530',
4 => 1642046735,
5 => 1642046735,
6 => '0.0.0.0',
7 => '0.0.0.0',
)]
Error code: dmlwriteexception
* line 489 of /lib/dml/moodle_database.php: dml_write_exception thrown
* line 1357 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
* line 1403 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
* line 540 of /lib/classes/session/manager.php: call to mysqli_native_moodle_database->insert_record()
* line 583 of /lib/classes/session/manager.php: call to core\session\manager::add_session_record()
* line 4693 of /lib/moodlelib.php: call to core\session\manager::login_user()
* line 306 of /opt/moosh/moosh.php: call to complete_user_login()
Does anybody have any idea why this might be happening? Happy to help out with a fix with some direction
The same error here when running moosh course-delete in many parallel threads (30 jobs deleting courses at the same time). Deleting 20.000 coursers this failed 30 times.
Moodle 3.11.6 moosh version 1.5
Default exception handler: Error escribiendo a la base de datos Debug: ERROR: duplicate key value violates unique constraint "mdl_sess_sid_uix"
DETAIL: Key (sid)=() already exists.
INSERT INTO mdl_sessions (state,sid,sessdata,userid,timemodified,timecreated,lastip,firstip) VALUES($1,$2,$3,$4,$5,$6,$7,$8) RETURNING id
[array (
'state' => 0,
'sid' => '',
'sessdata' => NULL,
'userid' => '73048',
'timemodified' => 1657628346,
'timecreated' => 1657628346,
'lastip' => '0.0.0.0',
'firstip' => '0.0.0.0',
)]
Error code: dmlwriteexception
* line 489 of /lib/dml/moodle_database.php: dml_write_exception thrown
* line 329 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end()
* line 1082 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
* line 1130 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->insert_record_raw()
* line 568 of /lib/classes/session/manager.php: call to pgsql_native_moodle_database->insert_record()
* line 611 of /lib/classes/session/manager.php: call to core\session\manager::add_session_record()
* line 4532 of /lib/moodlelib.php: call to core\session\manager::login_user()
* line 306 of /usr/bin/moosh: call to complete_user_login()