Commit ca87a619 authored by Barry Perlman's avatar Barry Perlman Committed by Yoni Fogel

[t:2947] Merge from tokudb.2947. Added errno to error log, don't take...

[t:2947] Merge from tokudb.2947.  Added errno to error log, don't take minicron lock for engine status.  I want to print engine status to error log, but the env isn't available everywhere, so that's not here (yet).

git-svn-id: file:///svn/toku/tokudb@24075 c7de825b-a66e-492c-adef-691d508d4ae1
parent e44aa0b8
...@@ -264,6 +264,10 @@ u_int32_t toku_get_checkpoint_period (CACHETABLE ct) { ...@@ -264,6 +264,10 @@ u_int32_t toku_get_checkpoint_period (CACHETABLE ct) {
return toku_minicron_get_period(&ct->checkpointer); return toku_minicron_get_period(&ct->checkpointer);
} }
u_int32_t toku_get_checkpoint_period_unlocked (CACHETABLE ct) {
return toku_minicron_get_period_unlocked(&ct->checkpointer);
}
// reserve 25% as "unreservable". The loader cannot have it. // reserve 25% as "unreservable". The loader cannot have it.
#define unreservable_memory(size) ((size)/4) #define unreservable_memory(size) ((size)/4)
......
...@@ -11,10 +11,13 @@ extern "C" { ...@@ -11,10 +11,13 @@ extern "C" {
#endif #endif
int toku_set_checkpoint_period(CACHETABLE ct, u_int32_t new_period); int toku_set_checkpoint_period(CACHETABLE ct, u_int32_t new_period);
u_int32_t toku_get_checkpoint_period(CACHETABLE ct);
//Effect: Change [end checkpoint (n) - begin checkpoint (n+1)] delay to //Effect: Change [end checkpoint (n) - begin checkpoint (n+1)] delay to
// new_period seconds. 0 means disable. // new_period seconds. 0 means disable.
u_int32_t toku_get_checkpoint_period(CACHETABLE ct);
u_int32_t toku_get_checkpoint_period_unlocked(CACHETABLE ct);
/****** /******
* *
* NOTE: multi_operation_lock is highest level lock * NOTE: multi_operation_lock is highest level lock
......
...@@ -117,11 +117,19 @@ u_int32_t ...@@ -117,11 +117,19 @@ u_int32_t
toku_minicron_get_period(struct minicron *p) toku_minicron_get_period(struct minicron *p)
{ {
int r = toku_pthread_mutex_lock(&p->mutex); assert(r==0); int r = toku_pthread_mutex_lock(&p->mutex); assert(r==0);
u_int32_t retval = p->period_in_seconds; u_int32_t retval = toku_minicron_get_period_unlocked(p);
r = toku_pthread_mutex_unlock(&p->mutex); assert(r==0); r = toku_pthread_mutex_unlock(&p->mutex); assert(r==0);
return retval; return retval;
} }
/* unlocked function for use by engine status which takes no locks */
u_int32_t
toku_minicron_get_period_unlocked(struct minicron *p)
{
u_int32_t retval = p->period_in_seconds;
return retval;
}
int int
toku_minicron_shutdown(struct minicron *p) { toku_minicron_shutdown(struct minicron *p) {
int r = toku_pthread_mutex_lock(&p->mutex); assert(r==0); int r = toku_pthread_mutex_lock(&p->mutex); assert(r==0);
......
...@@ -41,6 +41,7 @@ struct minicron { ...@@ -41,6 +41,7 @@ struct minicron {
int toku_minicron_setup (struct minicron *s, u_int32_t period_in_seconds, int(*f)(void *), void *arg); int toku_minicron_setup (struct minicron *s, u_int32_t period_in_seconds, int(*f)(void *), void *arg);
int toku_minicron_change_period(struct minicron *p, u_int32_t new_period); int toku_minicron_change_period(struct minicron *p, u_int32_t new_period);
u_int32_t toku_minicron_get_period(struct minicron *p); u_int32_t toku_minicron_get_period(struct minicron *p);
u_int32_t toku_minicron_get_period_unlocked(struct minicron *p);
int toku_minicron_shutdown(struct minicron *p); int toku_minicron_shutdown(struct minicron *p);
BOOL toku_minicron_has_been_shutdown(struct minicron *p); BOOL toku_minicron_has_been_shutdown(struct minicron *p);
......
...@@ -1473,7 +1473,7 @@ env_get_engine_status(DB_ENV * env, ENGINE_STATUS * engstat) { ...@@ -1473,7 +1473,7 @@ env_get_engine_status(DB_ENV * env, ENGINE_STATUS * engstat) {
engstat->max_time_ydb_lock_held = schedstat.max_time_ydb_lock_held; /* max time client threads held the ydb lock */ engstat->max_time_ydb_lock_held = schedstat.max_time_ydb_lock_held; /* max time client threads held the ydb lock */
} }
env_checkpointing_get_period(env, &(engstat->checkpoint_period)); // do not take ydb lock (take minicron lock, but that's a very ephemeral low-level lock) engstat->checkpoint_period = toku_get_checkpoint_period_unlocked(env->i->cachetable); // do not take any locks (not even minicron lock)
{ {
CHECKPOINT_STATUS_S cpstat; CHECKPOINT_STATUS_S cpstat;
toku_checkpoint_get_status(&cpstat); toku_checkpoint_get_status(&cpstat);
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
/* It evaluates the argument and then calls a function toku_do_assert() which takes all the hits for the branches not taken. */ /* It evaluates the argument and then calls a function toku_do_assert() which takes all the hits for the branches not taken. */
#include "c_dialects.h" #include "c_dialects.h"
#include "errno.h"
C_BEGIN C_BEGIN
...@@ -12,8 +13,8 @@ C_BEGIN ...@@ -12,8 +13,8 @@ C_BEGIN
#error NDEBUG should not be set #error NDEBUG should not be set
#endif #endif
void toku_do_assert_fail(const char*/*expr_as_string*/,const char */*fun*/,const char*/*file*/,int/*line*/) __attribute__((__visibility__("default"))) __attribute__((__noreturn__)); void toku_do_assert_fail(const char*/*expr_as_string*/,const char */*fun*/,const char*/*file*/,int/*line*/, int/*errno*/) __attribute__((__visibility__("default"))) __attribute__((__noreturn__));
void toku_do_assert(int,const char*/*expr_as_string*/,const char */*fun*/,const char*/*file*/,int/*line*/) __attribute__((__visibility__("default"))); void toku_do_assert(int,const char*/*expr_as_string*/,const char */*fun*/,const char*/*file*/,int/*line*/, int/*errno*/) __attribute__((__visibility__("default")));
// Define GCOV if you want to get test-coverage information that ignores the assert statements. // Define GCOV if you want to get test-coverage information that ignores the assert statements.
// #define GCOV // #define GCOV
...@@ -21,9 +22,9 @@ void toku_do_assert(int,const char*/*expr_as_string*/,const char */*fun*/,const ...@@ -21,9 +22,9 @@ void toku_do_assert(int,const char*/*expr_as_string*/,const char */*fun*/,const
extern void (*do_assert_hook)(void); // Set this to a function you want called after printing the assertion failure message but before calling abort(). By default this is NULL. extern void (*do_assert_hook)(void); // Set this to a function you want called after printing the assertion failure message but before calling abort(). By default this is NULL.
#if defined(GCOV) || TOKU_WINDOWS #if defined(GCOV) || TOKU_WINDOWS
#define assert(expr) toku_do_assert((expr) != 0, #expr, __FUNCTION__, __FILE__, __LINE__) #define assert(expr) toku_do_assert((expr) != 0, #expr, __FUNCTION__, __FILE__, __LINE__, errno)
#else #else
#define assert(expr) ((expr) ? (void)0 : toku_do_assert_fail(#expr, __FUNCTION__, __FILE__, __LINE__)) #define assert(expr) ((expr) ? (void)0 : toku_do_assert_fail(#expr, __FUNCTION__, __FILE__, __LINE__, errno))
#endif #endif
#ifdef GCOV #ifdef GCOV
......
/* -*- mode: C; c-basic-offset: 4 -*- */
#ident "Copyright (c) 2007-2010 Tokutek Inc. All rights reserved." #ident "Copyright (c) 2007-2010 Tokutek Inc. All rights reserved."
#include <toku_portability.h> #include <toku_portability.h>
...@@ -18,9 +19,9 @@ static void *backtrace_pointers[N_POINTERS]; ...@@ -18,9 +19,9 @@ static void *backtrace_pointers[N_POINTERS];
void (*do_assert_hook)(void) = NULL; void (*do_assert_hook)(void) = NULL;
void toku_do_assert_fail (const char* expr_as_string,const char *function,const char*file,int line) void toku_do_assert_fail (const char* expr_as_string,const char *function,const char*file,int line, int caller_errno)
{ {
fprintf(stderr, "%s:%d %s: Assertion `%s' failed\n", file,line,function,expr_as_string); fprintf(stderr, "%s:%d %s: Assertion `%s' failed (errno=%d)\n", file,line,function,expr_as_string, caller_errno);
// backtrace // backtrace
#if !TOKU_WINDOWS #if !TOKU_WINDOWS
...@@ -52,8 +53,8 @@ void toku_do_assert_fail (const char* expr_as_string,const char *function,const ...@@ -52,8 +53,8 @@ void toku_do_assert_fail (const char* expr_as_string,const char *function,const
abort(); abort();
} }
void toku_do_assert(int expr,const char* expr_as_string,const char *function,const char*file,int line) { void toku_do_assert(int expr,const char* expr_as_string,const char *function,const char*file,int line, int caller_errno) {
if (expr==0) { if (expr==0) {
toku_do_assert_fail(expr_as_string, function, file, line); toku_do_assert_fail(expr_as_string, function, file, line, caller_errno);
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment