Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-58692

Fatal error during upgrade to 3.3 duplicate key auth_mnet -> rpc_negotiation_timeout

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Blocker Blocker
    • 3.3
    • 3.3
    • Authentication, MNet
    • MOODLE_33_STABLE
    • MOODLE_33_STABLE
    • MDL-58692-master-authcfgnames
    • Hide
      1. Prepare a 3.2 site.
      2. Inject some values directly into the config_plugins table to simulate the problematic scenarios, for example:

        INSERT INTO mdl_config_plugins(plugin, name, value) VALUES ('auth/mnet', 'rpc_negotiation_timeout', 30);
        INSERT INTO mdl_config_plugins(plugin, name, value) VALUES ('auth_mnet', 'rpc_negotiation_timeout', 30);
        INSERT INTO mdl_config_plugins(plugin, name, value) VALUES ('auth/ldap', 'tmp_conflicting_setting', 'One');
        INSERT INTO mdl_config_plugins(plugin, name, value) VALUES ('auth_ldap', 'tmp_conflicting_setting', 'Two');
        

      3. Upgrade the site to 3.3.
      4. TEST: Make sure that the screen with upgrade results inform about detected mismatch. In the example above, the auth_mnet does not report anything as there is no conflict. But the auth_ldap should raise a warning as the value has different values.
      5. TEST: Check that value using the correct format has been kept:

        SELECT * FROM mdl_config_plugins WHERE name = 'tmp_conflicting_setting';
        

      6. TEST: Check that a notice has been stored in the upgrade log table:

        SELECT * FROM mdl_upgrade_log WHERE type = 1;
        

      7. Run the upgradelib.php tests in the 3.3 site:

        $ vendor/bin/phpunit lib/tests/upgradelib_test.php
        

      Show
      Prepare a 3.2 site. Inject some values directly into the config_plugins table to simulate the problematic scenarios, for example: INSERT INTO mdl_config_plugins(plugin, name, value) VALUES ('auth/mnet', 'rpc_negotiation_timeout', 30); INSERT INTO mdl_config_plugins(plugin, name, value) VALUES ('auth_mnet', 'rpc_negotiation_timeout', 30); INSERT INTO mdl_config_plugins(plugin, name, value) VALUES ('auth/ldap', 'tmp_conflicting_setting', 'One'); INSERT INTO mdl_config_plugins(plugin, name, value) VALUES ('auth_ldap', 'tmp_conflicting_setting', 'Two'); Upgrade the site to 3.3. TEST: Make sure that the screen with upgrade results inform about detected mismatch. In the example above, the auth_mnet does not report anything as there is no conflict. But the auth_ldap should raise a warning as the value has different values. TEST: Check that value using the correct format has been kept: SELECT * FROM mdl_config_plugins WHERE name = 'tmp_conflicting_setting'; TEST: Check that a notice has been stored in the upgrade log table: SELECT * FROM mdl_upgrade_log WHERE type = 1; Run the upgradelib.php tests in the 3.3 site: $ vendor/bin/phpunit lib/tests/upgradelib_test.php

      I was setting up a partner institution dataset, I got a fatal error while upgrading to master:

      Default exception handler: Error writing to database Debug: ERROR:  duplicate key value violates unique constraint "mdl_confplug_plunam_uix"
      DETAIL:  Key (plugin, name)=(auth_mnet, rpc_negotiation_timeout) already exists.
      UPDATE mdl_config_plugins SET plugin = $2 WHERE plugin = $1
      [array (
        0 => 'auth/mnet',
        1 => 'auth_mnet',
      )]
      Error code: dmlwriteexception
      * line 489 of /lib/dml/moodle_database.php: dml_write_exception thrown
      * line 242 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end()
      * line 1167 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
      * line 1780 of /lib/dml/moodle_database.php: call to pgsql_native_moodle_database->set_field_select()
      * line 51 of /auth/mnet/db/upgrade.php: call to moodle_database->set_field()
      * line 564 of /lib/upgradelib.php: call to xmldb_auth_mnet_upgrade()
      * line 1754 of /lib/upgradelib.php: call to upgrade_plugins()
      * line 181 of /admin/cli/upgrade.php: call to upgrade_noncore()
       
      !!! Error writing to database !!!
      !! ERROR:  duplicate key value violates unique constraint "mdl_confplug_plunam_uix"
      DETAIL:  Key (plugin, name)=(auth_mnet, rpc_negotiation_timeout) already exists.
      UPDATE mdl_config_plugins SET plugin = $2 WHERE plugin = $1
      [array (
        0 => 'auth/mnet',
        1 => 'auth_mnet',
      )]
      Error code: dmlwriteexception !!
      !! Stack trace: * line 489 of /lib/dml/moodle_database.php: dml_write_exception thrown
      * line 242 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end()
      * line 1167 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
      * line 1780 of /lib/dml/moodle_database.php: call to pgsql_native_moodle_database->set_field_select()
      * line 51 of /auth/mnet/db/upgrade.php: call to moodle_database->set_field()
      * line 564 of /lib/upgradelib.php: call to xmldb_auth_mnet_upgrade()
      * line 1754 of /lib/upgradelib.php: call to upgrade_plugins()
      * line 181 of /admin/cli/upgrade.php: call to upgrade_noncore()
       !!
      

      This error is related to MDL-12689 changes. I've read a bit of history and I see that auth_mnet uses auth_mnet as plugin namespace since MDL-23245 (was using auth/mnet for some vars and auth_mnet for others) that issue's patch (94cf0a1e) includes a upgrade process to get rid of auth/mnet records (https://github.com/moodle/moodle/commit/94cf0a1e#diff-ac50c3eece4435d5f244c987200646efR38) but it seems that the site I'm trying to upgrade have somehow both auth/mnet -> rpc_negotiation_timeout and auth_mnet -> rpc_negotiation_timeout. I believe this can be related with MDL-23220 it could have happened that there was a problem with that upgrade step.

      This can be a problem specific to this this var or to this site but this will probably not be the only site with this problem. We have different options:

      1. Remove auth_mnet upgrade step as the plugin is already supposed to be using auth_mnet (I've checked the codebase and I haven't found any get/set config to auth/xxx)
      2. Update all MDL-12689 upgrade steps to check first if the config var we are trying to set exists and if it does we respect the current value, if auth/xxx var and auth_xxx values differ we notify the user but continue with the upgrade, if they don't we just remove the auth/xxx one. We could also improve this by checking each of the plugin's config values giving always priority to the config namespace that was previously used (the value that was used by moodle before MDL-12689)
      3. Check if this is an isolated issue and we should ignore it

      I would vote for #2 if we don't have much time, but I think that something close to #3 would be better.

            mudrd8mz David Mudrák (@mudrd8mz)
            dmonllao David Monllaó
            David Monllaó David Monllaó
            Dan Poltawski Dan Poltawski
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.