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

mod_choice is unable to save a submitted choice in a mod_choice with limited answers and many submissions (Errorcode: modcannotsubmit)

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.8.8, 2.9.4, 3.0.3, 3.1.2
    • Fix Version/s: None
    • Component/s: Choice
    • Labels:
    • Testing Instructions:
      Hide

      1. Create a mod_choice activity with two options, both with a fixed limit (e.g. 20)
      2. Assign 19 students to the first choice.
      3. Using a 20th student, try to submit the first choice. This should work.
      4. Using a 21st student, try to submit the first choice. This should not work; in fact, selecting this choice should not be possible at all (regardless of this patch).
      5. Using the same student, try to submit the second choice. This should still work.

      Even better: Create a really large installation. Say, 65000 students, 22000 courses, each with some activity instances and block instances. All in all, you should come up with about 800.000 entries in mdl_context for this to work.
      Before the patch, submitting one choice takes between 3 - 7 seconds (i.e. due to the locking mechanism, if 2 - 3 persons do this at the same time, one of them will be unable to make a choice. modcannotsubmit will occur).
      After the patch, submitting one choice will take less than one second.

      Show
      1. Create a mod_choice activity with two options, both with a fixed limit (e.g. 20) 2. Assign 19 students to the first choice. 3. Using a 20th student, try to submit the first choice. This should work. 4. Using a 21st student, try to submit the first choice. This should not work; in fact, selecting this choice should not be possible at all (regardless of this patch). 5. Using the same student, try to submit the second choice. This should still work. Even better: Create a really large installation. Say, 65000 students, 22000 courses, each with some activity instances and block instances. All in all, you should come up with about 800.000 entries in mdl_context for this to work. Before the patch, submitting one choice takes between 3 - 7 seconds (i.e. due to the locking mechanism, if 2 - 3 persons do this at the same time, one of them will be unable to make a choice. modcannotsubmit will occur). After the patch, submitting one choice will take less than one second.
    • Affected Branches:
      MOODLE_28_STABLE, MOODLE_29_STABLE, MOODLE_30_STABLE, MOODLE_31_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-51606-master

      Description

      Hello,
      if i create a choice - activity with limited answers activated in the settings user cannot send/save their choice via the form.
      If i deactivate limited answer from choice settings, everything work fine.

      This happens because – on rather large installations – submitting one choice can take 3 - 7 seconds, because is_enrolled is called for every single user that has voted for the same option. Since the database is locked during that submission, others have to wait. However, a fixed timeout of 10 seconds is used for waiting, i.e. the second or third user that submits a choice at the same time will receive that timeout after (a little more than) 10 seconds.

      In our environment it is rather likely that 5, 10 or even 50 users will try to submit their choices at the same time, mostly since some teachers use this for FCFS signups. Consequently, locking the table is definitely a great idea, otherwise limits would be exceeded on a regular basis. Nevertheless, submission should be fast and unlikely to fail.

      Here is the error output from moodle:

      Ihre Auswahl konnte nicht gespeichert werden. Versuchen Sie es bitte noch einmal.
      Weitere Informationen über diesen Fehler

      Debug info:
      Error code: cannotsubmit

      Stack trace:

      line 481 of /lib/setuplib.php: moodle_exception thrown
      line 280 of /mod/choice/lib.php: call to print_error()
      line 75 of /mod/choice/view.php: call to choice_user_submit_response()

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            lestefan Stefan L
            Participants:
            Component watchers:
            Dan Marsden, Jake Dallimore, Jun Pataleta
            Votes:
            4 Vote for this issue
            Watchers:
            10 Start watching this issue

              Dates

              Created:
              Updated: