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

WiredTiger Mutex on Windows can block the server

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.0.2, 3.1.1
    • Affects Version/s: 3.0.0
    • Component/s: WiredTiger
    • Labels:
      None
    • Fully Compatible
    • ALL
    • 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.

      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);
      	}
      

            Assignee:
            michael.cahill@mongodb.com Michael Cahill (Inactive)
            Reporter:
            dupuisla Laurent Dupuis
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: