-
Bug
-
Resolution: Fixed
-
Minor
-
4.1.15
Two processes writing to the same user preference for the first time can result in a db exception:
NOTICE: PHP message: Default exception handler: Error writing to database Debug: ERROR: duplicate key value violates unique constraint "mdl_userpref_usenam_uix""
|
DETAIL: Key (userid, name)=(2, tool_sessbreak_var1) already exists."
|
INSERT INTO mdl_user_preferences (userid,name,value) VALUES($1,$2,$3) RETURNING id"
|
[array ("
|
'userid' => '2',"
|
'name' => 'tool_sessbreak_var1',"
|
'value' => '46',"
|
)]"
|
Error code: dmlwriteexception"
|
* line 500 of /lib/dml/moodle_database.php: dml_write_exception thrown"
|
* line 346 of /lib/dml/moodle_read_replica_trait.php: call to moodle_database->query_end()"
|
* line 358 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->read_replica_query_end()"
|
* line 1149 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()"
|
* line 1197 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->insert_record_raw()"
|
* line 1537 of /lib/moodlelib.php: call to pgsql_native_moodle_database->insert_recor..."
|
This is solved easily with a transaction, it would also be better solved via MDL-70974
- will be (partly) resolved by
-
MDL-70974 Have a convenience $DB->upsert method
-
- Open
-