From 0827d756276dfaaeac6873daae852c8263146294 Mon Sep 17 00:00:00 2001 From: Venkatesh Duggirala Date: Wed, 8 Oct 2014 21:54:35 +0530 Subject: Bug #18808072 MYSQLBINLOG USES LOCALTIME() TO PRINT EVENTS, CAUSES KERNEL MUTEX CONTENTION Problem: For every event read, mysqlbinlog calls localtime() which in turn calls stat(/etc/localtime) which is causing kernel mutex contention. Analysis and Fix: localtime() calls stat(/etc/localtime) for every instance of the call where as localtime_r() the reentrant version was optimized to store the read only tz internal structure. Hence it will not call stat(/etc/localtime). It will call only once at the beginning. The mysql server is calling localtime_r() and mysqlbinlog tool is one place where we are still using localtime(). Once the process (mysqlbinlog) is started if timezone is changed it will be not picked up the the process and it will continue with the same values as the beginning of the process. This behavior is in-lined with mysql server. Also adding localtime_r() and gmtime_r() support for windows. --- mysys/my_wincond.c | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) (limited to 'mysys') diff --git a/mysys/my_wincond.c b/mysys/my_wincond.c index 4794bb391b6..ac0166c87b8 100644 --- a/mysys/my_wincond.c +++ b/mysys/my_wincond.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -344,26 +344,4 @@ int pthread_attr_destroy(pthread_attr_t *connect_att) return 0; } -/**************************************************************************** -** Fix localtime_r() to be a bit safer -****************************************************************************/ - -struct tm *localtime_r(const time_t *timep,struct tm *tmp) -{ - if (*timep == (time_t) -1) /* This will crash win32 */ - { - bzero(tmp,sizeof(*tmp)); - } - else - { - struct tm *res=localtime(timep); - if (!res) /* Wrong date */ - { - bzero(tmp,sizeof(*tmp)); /* Keep things safe */ - return 0; - } - *tmp= *res; - } - return tmp; -} #endif /* __WIN__ */ -- cgit v1.2.1