Project

General

Profile

Bug #10543

Missing timeout default initialization in FixedSqlConnectionPool

Added by Steven Köhler 6 days ago. Updated 1 day ago.

Status:
Resolved
Priority:
Normal
Target version:
Start date:
06/23/2022
Due date:
% Done:

100%

Estimated time:

Description

While investigating a server crash I found a 'FixedSqlConnectionPool::getConnection(): timeout' error message in my server logs, which was thrown in the FixedSqlConnectionPool::handleTimeout function, which is called from FixedSqlConnectionPool::getConnection.

while (impl_->freeList.empty()) {
  LOG_WARN("no free connections, waiting for connection");
  if (impl_->timeout > std::chrono::steady_clock::duration::zero()) {
    if (impl_->connectionAvailable.wait_for(lock, impl_->timeout) == std::cv_status::timeout) {
      handleTimeout();
    }
  } else
    impl_->connectionAvailable.wait(lock);
}

Since I did not specify a timeout, and Wt does not set one by default (according to documentation), the handleTimeout function should not have been called. Turned out the timeout member variable does not get initialized, and since the std::chrono::duration default constructor does not initialize it either (see https://groups.google.com/a/isocpp.org/g/std-discussion/c/OcGX7Yj3meI), it just has a random value - in my case it must have been less than a few milliseconds, which, paired with enough simultaneous page calls (from a bot) caused the almost immediate exception.

Note: The following server crash itself was not caused by that exception directly, but happened due to https://redmine.webtoolkit.eu/issues/10483, which was not fixed in that server instance, and since the timeout exception occurred during the applications construction. So no additional issue there.

I implemented a fix for this issue and created a pull request: https://github.com/emweb/wt/pull/194.

#1

Updated by Roel Standaert 5 days ago

  • Status changed from New to Resolved
  • Assignee set to Steven Köhler
  • Target version set to 4.8.0
#2

Updated by Roel Standaert 1 day ago

  • Target version changed from 4.8.0 to 4.7.3
#3

Updated by Roel Standaert 1 day ago

  • % Done changed from 0 to 100

Also available in: Atom PDF