Merge lp:~jaypipes/drizzle/bugs into lp:~drizzle-trunk/drizzle/development
Proposed by
Jay Pipes
Status: | Merged | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Merged at revision: | not available | ||||||||||||||||||||||||
Proposed branch: | lp:~jaypipes/drizzle/bugs | ||||||||||||||||||||||||
Merge into: | lp:~drizzle-trunk/drizzle/development | ||||||||||||||||||||||||
Diff against target: |
129 lines (+23/-23) 2 files modified
drizzled/temporal_format.cc (+23/-22) drizzled/temporal_format.h (+0/-1) |
||||||||||||||||||||||||
To merge this branch: | bzr merge lp:~jaypipes/drizzle/bugs | ||||||||||||||||||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Brian Aker | Pending | ||
Drizzle Developers | Pending | ||
Review via email: mp+16579@code.launchpad.net |
To post a comment you must log in.
Fixes LP Bug #500031:
"dbt2 fails with 1024 connections"
After investigation into this, I discovered that there was a :match( ):
race condition in TemporalFormat:
TemporalFor mat::_re is the compiled PCRE regular expression object
inside each of the TemporalFormat objects, which are shared
among all threads and live in global scope.
Unfortunately, TemporalFormat: :match( ) was using the member :_match_ vector as its match state.
variable TemporalFormat:
At high concurrency, this means that the following race
condition could happen:
Thread 1 executes pcre_exec() and finds a match, therefore :_match_ vector of integers
populating TemporalFormat:
with the position offsets of the matched pieces of the temporal object.
Thread 1, during construction of the Temporal output of mat::match( ), uses these _match_vector position
TemporalFor
offsets in calling std::string::substr on a copy of the
matched string, essentially "cutting up" the string
into year, month, day, etc.
Thread 2 executes pcre_exec() and also finds a match, :_match_ vector to something
thereby changing TemporalFormat:
different
Thread 1 continues trying to use std::string: :substr( ),
but now uses offsets that are invalid for its string,
thereby producing an out_of_range exception.
The solution is to pull the TemporalFormat: :_match_ vector scope-level :match( ).
member variable and instead put a function-
match_vector variable on the stack inside TemporalFormat: