Bug #22305 SysLogHandler not thread safe
Submitted: 13 Sep 2006 12:40 Modified: 3 Nov 2006 13:15
Reporter: Stewart Smith Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S3 (Non-critical)
Version:5.0,5.1 OS:
Assigned to: Assigned Account CPU Architecture:Any

[13 Sep 2006 12:40] Stewart Smith
Description:
when logging a message, the following is called:

00077 LogHandler::append_impl(const char* pCategory, Logger::LoggerLevel level,
00078             const char* pMsg)
00079 {
00080   writeHeader(pCategory, level);
00081   if (m_count_repeated_messages <= 1)
00082     writeMessage(pMsg);
00083   else
00084   {
00085     BaseString str(pMsg);
00086     str.appfmt(" - Repeated %d times", m_count_repeated_messages);
00087     writeMessage(str.c_str());
00088   }
00089   m_count_repeated_messages= 0;
00090   writeFooter();
00091 }

but writeHeader sets up internal variables for severity and category for use by writeMessage.

There are no locks around these two, so it's possible to get log messages with incorrect severity and/or category.

How to repeat:
use SHM transporter for a higher probability of hitting this.

Suggested fix:
In SyslogHandler:
lock in writeHeader, unlock in writemessage.
[3 Nov 2006 4:32] Stewart Smith
same patch as for BUG#22313
[3 Nov 2006 13:15] Stewart Smith
marking as duplicate of BUG#22313