Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-17471

WiredTiger Mutex on Windows can block the server

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 3.0.0
    • Fix Version/s: 3.0.2, 3.1.1
    • Component/s: WiredTiger
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Backport Completed:
    • Steps To Reproduce:
      Hide

      Occurs on very large (>1 billion rows) bulk inserts.

      Seems to happen when cursors attempt to check for cache eviction. However it is difficult to obtain correct stack trace on Release build.

      Show
      Occurs on very large (>1 billion rows) bulk inserts. Seems to happen when cursors attempt to check for cache eviction. However it is difficult to obtain correct stack trace on Release build.

      Description

      The function __wt_cond_wait waits a conditional variable for usecs microseconds or for ever if the variable is zero. However, the implementation can lead to unexpected infinite wait if usecs become negative.

      	if (usecs > 0) {
      		milliseconds = usecs / 1000;
      		/*
      		 * 0 would mean the CV sleep becomes a TryCV which we do not
      		 * want
      		 */
      		if (milliseconds == 0)
      			milliseconds = 1;
      		ret = SleepConditionVariableCS(
      		    &cond->cond, &cond->mtx, milliseconds);
      	} else
      		ret = SleepConditionVariableCS(
      		    &cond->cond, &cond->mtx, INFINITE);
      

      This can be fixed by reviewing the code and using unsigned values for milliseconds (as it should be a DWORD cf MSDN)

      	DWORD milliseconds;
       
      	// .... code removed for clarity ....
       
      	if (usecs == 0)
      	{
      		ret = SleepConditionVariableCS(
      			&cond->cond, &cond->mtx, INFINITE);
      	}
      	else //if (usecs > 0) 
      	{
      		milliseconds = ((unsigned long)usecs) / 1000UL;
      		/*
      		 * 0 would mean the CV sleep becomes a TryCV which we do not
      		 * want
      		 */
      		if (milliseconds == 0)
      			milliseconds = 1;
      		ret = SleepConditionVariableCS(
      		    &cond->cond, &cond->mtx, milliseconds);
      	}
      

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: