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

Database Read-Only Replica (Slave): Fall back to primary when get record failed with MUST_EXIST

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • 4.2
    • Database SQL/XMLDB
    • None
    • MOODLE_402_STABLE

      When using read-only database option,

      Replica lag or not working can cause data inconsistency,

      (We had serious issues with it at a production site)

       

      e.g: When creating a course, the record is written to the primary,

      And immediately  we try to fetch it from the replica, If its not there,

      The course is partially created.

      Even after the replica catches up, that course is not usable.

      I Have this project that can help demonstrate the issue:

      https://github.com/SysBind/moodle-ro-replica

       

      I started  a little patch to fix this,

      If get_record_sql with MUST_EXIST couldn't fetch record from the replica,

      It will retry from the primary:

      https://github.com/SysBind/moodle/tree/master_ro_replica

       

      Reproduction Steps:

      • Run 2 postgres instances - primary & replica
      • Install clean moodle on it - configured to use the replica for  read-only queries
      • Configure 'latency' to 0
      • Stop the replication: SELECT pg_wal_replay_pause();
      • Create a course - after submitting we get dml_missing_record_exception
      • Resume the replication: SELECT pg_wal_replay_resume();
      • The course is still defective (No sections, not viewable under category)

            Unassigned Unassigned
            asaf-sysbind Asaf Ohayon
            Votes:
            6 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:

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