Uploaded image for project: 'MusicBrainz Server'
  1. MusicBrainz Server
  2. MBS-11896

Remove the unique_primary_for_locale triggers and associated functions

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2021-10-04
    • Component/s: Schema Change
    • Labels:
      None

      Description

      These triggers ensure that if an alias is set to primary_for_locale = true, we unset primary_for_locale on all other aliases for that locale & entity to avoid uniqueness violations on the *_alias_idx_primary index.

      There's a major problem here: cascading triggers do not mix well with dbmirror, and can break replication. This is because when row-level AFTER triggers are cascaded, the innermost recordchange trigger is run first (inverse of the actual statement order). This is exactly what caused MBS-9366, and is a very hard problem to fix in dbmirror properly; it's much safer to outright ban cascading updates on replicated tables.

      Even ignoring the replication issue, we don't need these triggers. Avoiding duplicate primary locales can be handled by the application (and already is). If it wasn't, it even seems better to have the application fail with a unique index violation (since that indicates it's not accounting the changes properly) than silently change the data.

        Attachments

          Activity

            People

            Assignee:
            reosarevok Nicolás Tamargo
            Reporter:
            bitmap Michael Wiencek
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Packages

                Version Package
                2021-10-04