Permalink
Browse files

Port jsobel's MEMCACHE_DIRTY changes and Paul's change "Export libmcc…

… statistics to SHOW STATUS" to 5.1.38.

Summary:
We use the MEMCACHE_DIRTY keyword to list keys which needed to
be deleted from memcache via mcproxy.  This is just a straight port from
5.0.84 to 5.1.38.

Export the following to SHOW STATUS:
Libmcc_errors      - # of errors returned by libmcc
Libmcc_keys        - # of keys passed to libmcc
Libmcc_long_reqs   - # of times which libmcc spent greater than the
                     warning time processing requests
Libmcc_reqs        - # of calls to libmcc
Libmcc_usecs       - Total number of microseconds seconds spent in libmcc

I also pulled in some time functions from innobase/ut/ut0ut.c to help
facilitate the tracking of time to use microseconds and to protect
against gettimeofday going backwards or failing.

Additionally included Mark's change "Don't print warning on slow memcache dirty
operation."

Minimal update of affected Makefile.in files and configure file.

Fixed two warnings and a compile error I didn't catch until I built the RPM
and removed a few unnecessary diffs from the Makefile.in.

Reviewed By: mcallaghan

Test Plan:
run mysql-test-run. The current tests will just exercise the
code path in the lexer to provide valgrind coverage for now.  We need a
more complete test to deal with mcproxy + slave execution and also
executing the MEMCACHE_DIRTY keys on the master, which is not currently
done, but the ECDC team may want to do this.
1 parent d431a5b commit beaf2ad1072ea81eb2b09ca14b745bd8a794c61b ryandmack committed with steaphangreene Sep 29, 2009
View
@@ -0,0 +1,21 @@
+#! /bin/sh
+
+path=`dirname $0`
+
+if test ! -f sql/mysqld.cc
+then
+echo "You must run this script from the MySQL top-level directory"
+exit 1
+fi
+# bug in mysql bld system.
+touch sql/sql_yacc.yy
+
+. "$path/SETUP.sh"
+
+extra_configs="--with-blackhole-storage-engine --with-memcache-path='/root/usr/local' -with-server-suffix=-FB_Memcache --host=x86_64-redhat-linux-gnu --build=x86_64-redhat-inux-gnu --target=x86_64-redhat-linux '--program-prefix=' --prefix=/usr --exec-prefix=usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --incudedir=/usr/include --libdir=/usr/lib64 --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/usr/com --mandir=/usr/share/man --infodir=/usr/share/info --with-realine --with-openssl --with-debug --enable-shared --with-bench --localstatedir=/var/libmysql --with-unix-socket-path=/var/lib/mysql/mysql.sock --with-mysqld-user=mysql --wit-extra-charsets=all --with-innodb --with-berkeley-db --enable-local-infile --enable-lagefile --enable-thread-safe-client --disable-dependency-tracking --with-named-thread-lbs=-lpthread 'CFLAGS=-O2 -g -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -no-strict-aliasing -fwrapv' 'CXXFLAGS=-O2 -g -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LRGEFILE_SOURCE -fno-strict-aliasing -fwrapv -fno-rtti -fno-exceptions' 'FFLAGS=-O2 -g uild_alias=x86_64-redhat-linux-gnu' host_alias=x86_64-redhat-linux-gnu target_alias=x8_64-redhat-linux"
+
+#strip=yes
+
+. "$path/FINISH.sh"
+
+
View
@@ -931,6 +931,9 @@ ZLIB_DEPS
ZLIB_LIBS
zlib_dir
GETCONF
+LIBMEMCACHE
+NO_MEMCACHE_FALSE
+NO_MEMCACHE_TRUE
MYSQLD_USER
MYSQL_TCP_PORT_DEFAULT
MYSQL_TCP_PORT
@@ -1153,6 +1156,7 @@ with_tcp_port
with_mysqld_user
enable_local_infile
enable_grant_options
+with_memcache_path
enable_largefile
with_zlib_dir
with_libwrap
@@ -1898,6 +1902,8 @@ Optional Packages:
Which port to use for MySQL services (default 3306)
--with-mysqld-user=username
What user the mysqld daemon shall be run as.
+ --with-memcache-path=memcachepath
+ Path to memcache library and includes.
--with-zlib-dir=no|bundled|DIR
Provide MySQL with a custom location of compression
library. Given DIR, zlib binary is assumed to be in
@@ -19487,6 +19493,42 @@ _ACEOF
$as_echo "no" >&6; }
fi
+# If we should compile with memcache
+{ $as_echo "$as_me:$LINENO: checking If we should compile with memcache" >&5
+$as_echo_n "checking If we should compile with memcache... " >&6; }
+
+# Check whether --with-memcache-path was given.
+if test "${with_memcache_path+set}" = set; then
+ withval=$with_memcache_path; LIBMEMCACHE=$withval
+else
+ LIBMEMCACHE=no
+
+fi
+
+if test "$LIBMEMCACHE" = "no"
+then
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: yes: path is \"$LIBMEMCACHE\"" >&5
+$as_echo "yes: path is \"$LIBMEMCACHE\"" >&6; }
+
+cat >>confdefs.h <<\_ACEOF
+#define ENABLE_LIBMEMCACHE 1
+_ACEOF
+
+fi
+
+ if test "$LIBMEMCACHE" = "no"; then
+ NO_MEMCACHE_TRUE=
+ NO_MEMCACHE_FALSE='#'
+else
+ NO_MEMCACHE_TRUE='#'
+ NO_MEMCACHE_FALSE=
+fi
+
+
+
# Check whether --enable-largefile was given.
if test "${enable_largefile+set}" = set; then
View
@@ -806,6 +806,26 @@ else
AC_MSG_RESULT([no])
fi
+# If we should compile with memcache
+AC_MSG_CHECKING(If we should compile with memcache)
+AC_ARG_WITH(memcache-path,
+ [ --with-memcache-path=memcachepath
+ Path to memcache library and includes.],
+ [ LIBMEMCACHE=$withval ],
+ [ LIBMEMCACHE=no]
+ )
+if test "$LIBMEMCACHE" = "no"
+then
+ AC_MSG_RESULT([no])
+else
+ AC_MSG_RESULT([yes: path is "$LIBMEMCACHE"])
+ AC_DEFINE([ENABLE_LIBMEMCACHE], [1],
+ [Enable the use of libmcc])
+fi
+
+AM_CONDITIONAL(NO_MEMCACHE, test "$LIBMEMCACHE" = "no")
+AC_SUBST(LIBMEMCACHE)
+
MYSQL_SYS_LARGEFILE
# Types that must be checked AFTER large file support is checked
View
@@ -879,6 +879,10 @@ time_t my_time_possible_from_micro(ulonglong microtime);
extern my_bool my_gethwaddr(uchar *to);
extern int my_getncpus();
+int my_usectime(ulong *sec, ulong *ms);
+double my_usecdiff_now(int start_res, ulong start_sec, ulong start_usec);
+void my_print_timestamp(FILE* file);
+
#ifdef HAVE_SYS_MMAN_H
#include <sys/mman.h>
@@ -0,0 +1,8 @@
+drop table if exists t1;
+CREATE TABLE t1 (
+i int(11) default NULL
+);
+INSERT INTO t1 VALUES (1) MEMCACHE_DIRTY "k1";
+INSERT INTO t1 VALUES (1) MEMCACHE_DIRTY "k1","k2";
+INSERT INTO t1 VALUES (1) MEMCACHE_DIRTY "k1","k2","k3";
+drop table t1;
@@ -0,0 +1,23 @@
+#
+# Simple test for blackhole example
+# Taken from the select test
+#
+-- source include/not_embedded.inc
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+CREATE TABLE t1 (
+ i int(11) default NULL
+);
+
+INSERT INTO t1 VALUES (1) MEMCACHE_DIRTY "k1";
+INSERT INTO t1 VALUES (1) MEMCACHE_DIRTY "k1","k2";
+INSERT INTO t1 VALUES (1) MEMCACHE_DIRTY "k1","k2","k3";
+
+# cleanup
+drop table t1;
+
+
+# End of tests
View
@@ -52,7 +52,8 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
my_gethostbyname.c rijndael.c my_aes.c sha1.c \
my_handler.c my_netware.c my_largepage.c \
my_memmem.c stacktrace.c \
- my_windac.c my_access.c base64.c my_libwrap.c
+ my_windac.c my_access.c base64.c my_libwrap.c \
+ my_ut.c
EXTRA_DIST = thr_alarm.c thr_lock.c my_pthread.c my_thr_init.c \
thr_mutex.c thr_rwlock.c \
CMakeLists.txt mf_soundex.c \
View
@@ -116,7 +116,8 @@ am_libmysys_a_OBJECTS = my_init.$(OBJEXT) my_getwd.$(OBJEXT) \
my_aes.$(OBJEXT) sha1.$(OBJEXT) my_handler.$(OBJEXT) \
my_netware.$(OBJEXT) my_largepage.$(OBJEXT) \
my_memmem.$(OBJEXT) stacktrace.$(OBJEXT) my_windac.$(OBJEXT) \
- my_access.$(OBJEXT) base64.$(OBJEXT) my_libwrap.$(OBJEXT)
+ my_access.$(OBJEXT) base64.$(OBJEXT) my_libwrap.$(OBJEXT) \
+ my_ut.$(OBJEXT)
libmysys_a_OBJECTS = $(am_libmysys_a_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
depcomp = $(SHELL) $(top_srcdir)/depcomp
@@ -499,7 +500,8 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
my_gethostbyname.c rijndael.c my_aes.c sha1.c \
my_handler.c my_netware.c my_largepage.c \
my_memmem.c stacktrace.c \
- my_windac.c my_access.c base64.c my_libwrap.c
+ my_windac.c my_access.c base64.c my_libwrap.c \
+ my_ut.c
EXTRA_DIST = thr_alarm.c thr_lock.c my_pthread.c my_thr_init.c \
thr_mutex.c thr_rwlock.c \
@@ -679,6 +681,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/my_symlink.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/my_symlink2.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/my_sync.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/my_ut.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/my_vle.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/my_windac.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/my_write.Po@am__quote@
View
@@ -0,0 +1,101 @@
+/*******************************************************************
+Various utilities for Innobase.
+
+(c) 1994, 1995 Innobase Oy
+
+Created 5/11/1994 Heikki Tuuri
+********************************************************************/
+
+#include "mysys_priv.h"
+int
+my_usectime(
+/*========*/
+ /* out: 0 on success, -1 otherwise */
+ ulong* sec, /* out: seconds since the Epoch */
+ ulong* ms) /* out: microseconds since the Epoch+*sec */
+{
+ struct timeval tv;
+ int ret;
+ int errno_gettimeofday;
+ int i;
+
+ for (i = 0; i < 10; i++) {
+
+ ret = gettimeofday(&tv, NULL);
+
+ if (ret == -1) {
+ errno_gettimeofday = errno;
+ my_print_timestamp(stderr);
+ fprintf(stderr, " MySQL: gettimeofday(): %s\n",
+ strerror(errno_gettimeofday));
+ usleep(100000); /* 0.1 sec */
+ errno = errno_gettimeofday;
+ } else {
+ break;
+ }
+ }
+
+ if (ret != -1) {
+ *sec = (ulong) tv.tv_sec;
+ *ms = (ulong) tv.tv_usec;
+ }
+
+ return(ret);
+}
+
+/**************************************************************
+Returns difference in microseconds between (start_sec,start_usec) and now.
+Returns 0 when the result would be negative or the calls to my_usectime failed. */
+
+double
+my_usecdiff_now(
+/*========================*/
+ /* out: difference in microseconds */
+ int start_res, /* in: return from start my_usectime call */
+ ulong start_sec, /* in: sec from start my_usectime call */
+ ulong start_usec) /* in: ms from start my_usectime call */
+{
+ int end_res;
+ ulong end_sec, end_usec;
+ double result;
+
+ end_res = my_usectime(&end_sec, &end_usec);
+
+ if (end_res || start_res)
+ return 0; /* my_usectime failed */
+
+ double end_mics = end_sec * 1000000LL + end_usec;
+ double start_mics = start_sec * 1000000LL + start_usec;
+ result = end_mics - start_mics;
+
+ return (result >= 0) ? result : 0;
+}
+
+/**************************************************************
+Prints a timestamp to a file. */
+
+void
+my_print_timestamp(
+ /*===============*/
+ FILE* file) /* in: file where to print */
+{
+ struct tm cal_tm;
+ struct tm* cal_tm_ptr;
+ time_t tm;
+
+ time(&tm);
+
+#ifdef HAVE_LOCALTIME_R
+ localtime_r(&tm, &cal_tm);
+ cal_tm_ptr = &cal_tm;
+#else
+ cal_tm_ptr = localtime(&tm);
+#endif
+ fprintf(file,"%02d%02d%02d %2d:%02d:%02d",
+ cal_tm_ptr->tm_year % 100,
+ cal_tm_ptr->tm_mon + 1,
+ cal_tm_ptr->tm_mday,
+ cal_tm_ptr->tm_hour,
+ cal_tm_ptr->tm_min,
+ cal_tm_ptr->tm_sec);
+}
@@ -0,0 +1,8 @@
+File=none
+Name=MEMCACHE_DIRTY
+Version=1.0
+Author=Facebook
+License=GPL
+ChangeLog=
+2009-08-05
+ps: Initial release
View
@@ -23,6 +23,10 @@ pkgplugindir = $(pkglibdir)/plugin
INCLUDES = @ZLIB_INCLUDES@ \
-I$(top_builddir)/include -I$(top_srcdir)/include \
-I$(top_srcdir)/regex -I$(srcdir) $(openssl_includes)
+if !NO_MEMCACHE
+INCLUDES += -I@LIBMEMCACHE@/include
+endif
+
WRAPLIBS= @WRAPLIBS@
SUBDIRS = share
libexec_PROGRAMS = mysqld
@@ -39,6 +43,10 @@ SUPPORTING_LIBS = $(top_builddir)/vio/libvio.a \
$(top_builddir)/strings/libmystrings.a
mysqld_DEPENDENCIES= @mysql_plugin_libs@ $(SUPPORTING_LIBS) libndb.la
LDADD = $(SUPPORTING_LIBS) @ZLIB_LIBS@ @NDB_SCI_LIBS@
+if !NO_MEMCACHE
+LDADD += -L$(LIBMEMCACHE)/lib -lmcc -L/usr/local/lib -levent -lcrypto
+endif
+
mysqld_LDADD = libndb.la \
@MYSQLD_EXTRA_LDFLAGS@ \
@pstack_libs@ \
@@ -143,6 +151,10 @@ DEFS = -DMYSQL_SERVER \
-DHAVE_EVENT_SCHEDULER \
@DEFS@
+if !NO_MEMCACHE
+DEFS += -DLIBMEMCACHE
+endif
+
BUILT_MAINT_SRC = sql_yacc.cc sql_yacc.h
BUILT_SOURCES = $(BUILT_MAINT_SRC) lex_hash.h link_sources
EXTRA_DIST = udf_example.c udf_example.def $(BUILT_MAINT_SRC) \
Oops, something went wrong.

0 comments on commit beaf2ad

Please sign in to comment.