query_log output is mangled due to multithreadedness

Bug #1001199 reported by Henrik Ingo
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Drizzle
Fix Released
Medium
Stewart Smith

Bug Description

When enabling query_log plugin and directing 32 sysbench threads against it, I get output like below:

# start_ts=2012-05-18T10:56:32.046310
# session_id=12 query_id=11 rows_examined=1 rows_sent=1 tmp_tables=0 warnings=0
# execution_time=# start_ts=2012-05-18T10:56:32.045882
# session_id=12 query_id=11 rows_examined=1 rows_sent=1 tmp_tables=HERE id=0lock_time=
 warnings=0
# execution_time=0.002518 session_time=0.034174
# error=false
# schema="sbtest"
SELECT pad FROM sbtest1 WHERE id=20176010;
#
# start_ts=2012-05-18T10:56:32.046310
# session_id=12 query_id=11 rows_examined=1 rows_sent=1 tmp_tables=0 warnings=0
# execution_time=# start_ts=2012-05-18T10:56:32.045882
# session_id=12 query_id=11 rows_examined=1 rows_sent=1 tmp_tables=HERE id=0lock_time=
 warnings=0
# execution_time=0.002518 session_time=0.034174
# error=false
# schema="sbtest"
SELECT pad FROM sbtest1 WHERE id=20176010;
#
0.031333 lock_time=0.002518 session_time=0.034174
# error=false
# schema="sbtest"
SELECT pad FROM sbtest1 WHERE id=20176010;
#
....

It seems that output from multiple threads is mixed together.

Related branches

Henrik Ingo (hingo)
tags: added: query-log-plugin
Revision history for this message
Daniel Nichter (daniel-nichter) wrote :

Henrik,

Does logging_query have this problem too? Its code says:

    // a single write has a kernel thread lock, thus no need mutex guard this
    wrv= write(fd, msgbuf.c_str(), msgbuf.length());
    assert(wrv == msgbuf.length());

Whereas query_log does,

    _fh << "# start_ts=" << event->ts
    ...

which isn't thread-safe (and yes, that's my fault :-). If write() is indeed thread-safe, then it will be easy to make query_log use it like logginq_query.

Revision history for this message
Henrik Ingo (hingo) wrote :

I did not try logging_query. I'll let you know if I ever do. (This is on a work computer that I occasionally play with.)

Revision history for this message
Stewart Smith (stewart) wrote : Re: [Bug 1001199] Re: query_log output is mangled due to multithreadedness

On Fri, 18 May 2012 14:12:21 -0000, Daniel Nichter <email address hidden> wrote:
> Does logging_query have this problem too? Its code says:
>
> // a single write has a kernel thread lock, thus no need mutex guard this
> wrv= write(fd, msgbuf.c_str(), msgbuf.length());
> assert(wrv == msgbuf.length());
>
> Whereas query_log does,
>
> _fh << "# start_ts=" << event->ts
> ...
>
> which isn't thread-safe (and yes, that's my fault :-). If write() is
> indeed thread-safe, then it will be easy to make query_log use it like
> logginq_query.

The write() will be safe, the << operator explicitly isn't.

--
Stewart Smith

Stewart Smith (stewart)
Changed in drizzle:
status: New → Fix Committed
importance: Undecided → Medium
assignee: nobody → Stewart Smith (stewart)
milestone: none → 7.2.5
Stewart Smith (stewart)
Changed in drizzle:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.