Uploaded image for project: 'MariaDB MaxScale'
  1. MariaDB MaxScale
  2. MXS-3023

worker id overflow

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Fixed
    • 2.3.19
    • 2.3.21, 2.4.10
    • Core
    • None

    Description

      RoutingWorker* RoutingWorker::pick_worker()
      {
          static int id_generator = 0;
          int id = this_unit.id_min_worker
              + (mxb::atomic::add(&id_generator, 1, mxb::atomic::RELAXED) % this_unit.nWorkers);
          return get(id);
      }
      

      In code above, id_generator is int, when it overflows, it becomes negative integer, then we will have an invalid worker_id in 2.2.

      in 2.3, it's different, but `get(id)` will return nullptr, this requires the calling method to check if worker is empty. Apparently, gw_process_one_new_client is not doing it:

      1487     mxs::RoutingWorker* worker = mxs::RoutingWorker::pick_worker();
      1488
      1489     worker->execute([=]() {
      

      suggested fix:

      change id_generator to unsigned type

      Attachments

        Activity

          People

            markus makela markus makela
            daniel_xu_forever danielforever
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.