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

worker id overflow

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3.19
    • Fix Version/s: 2.4.10, 2.3.21
    • Component/s: Core
    • Labels:
      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

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

              Dates

              Created:
              Updated:
              Resolved: