Uploaded image for project: 'SonarQube'
  1. SonarQube
  2. SONAR-5681

When a change occurs on the DB, the Elasticsearch index must be dropped

    XMLWordPrintable

    Details

      Description

      In the following cases, the Elasticsearch index can be desynchronized:

      1. Update of SonarQube that implies a DB migration
      2. Change DB from one vendor to another, for instance from H2 to Oracle
      3. Restore a previous DB backup

      Currently, if a user follows the upgrade guide, the data directory is by definition empty. But if for any reason, this user would like to copy/paste the previous Elasticsearch data directory, we should detect such operation and drop/re-create all indices.

      Solution

      1. Execution of DB migration
        The DB version (ID of the last executed migration) is stored in Elasticsearch metadata. At startup it is compared with the effective version. If different, then all Elasticsearch indices are dropped, so that they will be automatically re-created and populated.
      2. Change DB vendor
        The DB vendor (mysql, oracle, ...) is stored in Elasticsearch metadata. At startup is it compared with the effective DB vendor. If different, then all Elasticsearch indices are dropped, so that they will be automatically re-created and populated.
      3. Restore DB backup
        Can't be technically implemented.

      SonarCloud

      SonarCloud is frequently upgraded. Most of times it's not required to drop all Elastichsearch indices. The non-documented boolean property sonar.search.disableDropOnDbMigration should be implemented in order to decrease duration of service shutdown. By default value is false.
      The development team should carefully notify SonarCloud ops team when a milestone requires to manually drop some indices.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              simon.brandhof Simon Brandhof (Inactive)
              Reporter:
              freddy.mallet Freddy Mallet (Inactive)
              Votes:
              6 Vote for this issue
              Watchers:
              12 Start watching this issue

                Dates

                Due:
                Created:
                Updated:
                Resolved: