Uploaded image for project: 'phpBB'
  1. phpBB
  2. PHPBB-10100

Race condition in unique_id() on heavily busy database.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 3.0.9-RC1
    • 3.0.8
    • None
    • None

      [22:04:36] <mbox> hello.. i have a suggestion for the unique_id() function, to improve performance on MyISAM. it's this... reverse the order of the two set_config lines so that the timestamp is set in the database before the random seed.
      [22:05:23] <mbox> this stops it from getting out of control when there's high contention on the phpbb_config table
      [22:06:19] <mbox> when it would get 10 seconds behind for any reason, any new unique_id call is generating 2 calls... first, setting the value... then setting the timestamp
      [22:07:58] <mbox> i can't think of how to explain it better, but the result was more and more threads being created and contending for that lock, but they had to get it twice before their timestamp got set. setting it first will greatly reduce the number of threads trying to seed it.
      [22:11:00] <mbox> it was bringing down my database server.
      [22:47:40] <mbox> this poorly made diagram should help explain the race condition i mentioned earlier: http://i.imgur.com/wR3S3.png
      [22:47:46] <mbox> hope it helps someone other than me. enjoy.

        1. wR3S3.png
          27 kB
          Andreas Fischer [X]

            bantu Andreas Fischer [X] (Inactive)
            bantu Andreas Fischer [X] (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: