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

Addresses #1792 refs[t:1792] Added logger lock info to engine status.

git-svn-id: file:///svn/toku/tokudb@14821 c7de825b-a66e-492c-adef-691d508d4ae1
parent 3381fb65
...@@ -45,6 +45,7 @@ typedef struct __toku_db_btree_stat64 { ...@@ -45,6 +45,7 @@ typedef struct __toku_db_btree_stat64 {
typedef struct __toku_engine_status { typedef struct __toku_engine_status {
char now[26]; /* time of engine status query (i.e. now) */ char now[26]; /* time of engine status query (i.e. now) */
u_int32_t ydb_lock_ctr; /* how many times has ydb lock been taken/released */ u_int32_t ydb_lock_ctr; /* how many times has ydb lock been taken/released */
u_int32_t logger_lock_ctr; /* how many times has logger lock been taken/released */
u_int32_t checkpoint_period; /* delay between automatic checkpoints */ u_int32_t checkpoint_period; /* delay between automatic checkpoints */
u_int32_t checkpoint_footprint; /* state of checkpoint procedure */ u_int32_t checkpoint_footprint; /* state of checkpoint procedure */
char checkpoint_time_begin[26]; /* time of last checkpoint begin */ char checkpoint_time_begin[26]; /* time of last checkpoint begin */
......
...@@ -45,6 +45,7 @@ typedef struct __toku_db_btree_stat64 { ...@@ -45,6 +45,7 @@ typedef struct __toku_db_btree_stat64 {
typedef struct __toku_engine_status { typedef struct __toku_engine_status {
char now[26]; /* time of engine status query (i.e. now) */ char now[26]; /* time of engine status query (i.e. now) */
u_int32_t ydb_lock_ctr; /* how many times has ydb lock been taken/released */ u_int32_t ydb_lock_ctr; /* how many times has ydb lock been taken/released */
u_int32_t logger_lock_ctr; /* how many times has logger lock been taken/released */
u_int32_t checkpoint_period; /* delay between automatic checkpoints */ u_int32_t checkpoint_period; /* delay between automatic checkpoints */
u_int32_t checkpoint_footprint; /* state of checkpoint procedure */ u_int32_t checkpoint_footprint; /* state of checkpoint procedure */
char checkpoint_time_begin[26]; /* time of last checkpoint begin */ char checkpoint_time_begin[26]; /* time of last checkpoint begin */
......
...@@ -45,6 +45,7 @@ typedef struct __toku_db_btree_stat64 { ...@@ -45,6 +45,7 @@ typedef struct __toku_db_btree_stat64 {
typedef struct __toku_engine_status { typedef struct __toku_engine_status {
char now[26]; /* time of engine status query (i.e. now) */ char now[26]; /* time of engine status query (i.e. now) */
u_int32_t ydb_lock_ctr; /* how many times has ydb lock been taken/released */ u_int32_t ydb_lock_ctr; /* how many times has ydb lock been taken/released */
u_int32_t logger_lock_ctr; /* how many times has logger lock been taken/released */
u_int32_t checkpoint_period; /* delay between automatic checkpoints */ u_int32_t checkpoint_period; /* delay between automatic checkpoints */
u_int32_t checkpoint_footprint; /* state of checkpoint procedure */ u_int32_t checkpoint_footprint; /* state of checkpoint procedure */
char checkpoint_time_begin[26]; /* time of last checkpoint begin */ char checkpoint_time_begin[26]; /* time of last checkpoint begin */
......
...@@ -45,6 +45,7 @@ typedef struct __toku_db_btree_stat64 { ...@@ -45,6 +45,7 @@ typedef struct __toku_db_btree_stat64 {
typedef struct __toku_engine_status { typedef struct __toku_engine_status {
char now[26]; /* time of engine status query (i.e. now) */ char now[26]; /* time of engine status query (i.e. now) */
u_int32_t ydb_lock_ctr; /* how many times has ydb lock been taken/released */ u_int32_t ydb_lock_ctr; /* how many times has ydb lock been taken/released */
u_int32_t logger_lock_ctr; /* how many times has logger lock been taken/released */
u_int32_t checkpoint_period; /* delay between automatic checkpoints */ u_int32_t checkpoint_period; /* delay between automatic checkpoints */
u_int32_t checkpoint_footprint; /* state of checkpoint procedure */ u_int32_t checkpoint_footprint; /* state of checkpoint procedure */
char checkpoint_time_begin[26]; /* time of last checkpoint begin */ char checkpoint_time_begin[26]; /* time of last checkpoint begin */
......
...@@ -45,6 +45,7 @@ typedef struct __toku_db_btree_stat64 { ...@@ -45,6 +45,7 @@ typedef struct __toku_db_btree_stat64 {
typedef struct __toku_engine_status { typedef struct __toku_engine_status {
char now[26]; /* time of engine status query (i.e. now) */ char now[26]; /* time of engine status query (i.e. now) */
u_int32_t ydb_lock_ctr; /* how many times has ydb lock been taken/released */ u_int32_t ydb_lock_ctr; /* how many times has ydb lock been taken/released */
u_int32_t logger_lock_ctr; /* how many times has logger lock been taken/released */
u_int32_t checkpoint_period; /* delay between automatic checkpoints */ u_int32_t checkpoint_period; /* delay between automatic checkpoints */
u_int32_t checkpoint_footprint; /* state of checkpoint procedure */ u_int32_t checkpoint_footprint; /* state of checkpoint procedure */
char checkpoint_time_begin[26]; /* time of last checkpoint begin */ char checkpoint_time_begin[26]; /* time of last checkpoint begin */
......
...@@ -349,6 +349,7 @@ int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__un ...@@ -349,6 +349,7 @@ int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__un
printf("typedef struct __toku_engine_status {\n"); printf("typedef struct __toku_engine_status {\n");
printf(" char now[26]; /* time of engine status query (i.e. now) */ \n"); printf(" char now[26]; /* time of engine status query (i.e. now) */ \n");
printf(" u_int32_t ydb_lock_ctr; /* how many times has ydb lock been taken/released */ \n"); printf(" u_int32_t ydb_lock_ctr; /* how many times has ydb lock been taken/released */ \n");
printf(" u_int32_t logger_lock_ctr; /* how many times has logger lock been taken/released */ \n");
printf(" u_int32_t checkpoint_period; /* delay between automatic checkpoints */ \n"); printf(" u_int32_t checkpoint_period; /* delay between automatic checkpoints */ \n");
printf(" u_int32_t checkpoint_footprint; /* state of checkpoint procedure */ \n"); printf(" u_int32_t checkpoint_footprint; /* state of checkpoint procedure */ \n");
printf(" char checkpoint_time_begin[26]; /* time of last checkpoint begin */ \n"); printf(" char checkpoint_time_begin[26]; /* time of last checkpoint begin */ \n");
......
...@@ -45,6 +45,7 @@ typedef struct __toku_db_btree_stat64 { ...@@ -45,6 +45,7 @@ typedef struct __toku_db_btree_stat64 {
typedef struct __toku_engine_status { typedef struct __toku_engine_status {
char now[26]; /* time of engine status query (i.e. now) */ char now[26]; /* time of engine status query (i.e. now) */
u_int32_t ydb_lock_ctr; /* how many times has ydb lock been taken/released */ u_int32_t ydb_lock_ctr; /* how many times has ydb lock been taken/released */
u_int32_t logger_lock_ctr; /* how many times has logger lock been taken/released */
u_int32_t checkpoint_period; /* delay between automatic checkpoints */ u_int32_t checkpoint_period; /* delay between automatic checkpoints */
u_int32_t checkpoint_footprint; /* state of checkpoint procedure */ u_int32_t checkpoint_footprint; /* state of checkpoint procedure */
char checkpoint_time_begin[26]; /* time of last checkpoint begin */ char checkpoint_time_begin[26]; /* time of last checkpoint begin */
......
...@@ -45,6 +45,7 @@ typedef struct __toku_db_btree_stat64 { ...@@ -45,6 +45,7 @@ typedef struct __toku_db_btree_stat64 {
typedef struct __toku_engine_status { typedef struct __toku_engine_status {
char now[26]; /* time of engine status query (i.e. now) */ char now[26]; /* time of engine status query (i.e. now) */
u_int32_t ydb_lock_ctr; /* how many times has ydb lock been taken/released */ u_int32_t ydb_lock_ctr; /* how many times has ydb lock been taken/released */
u_int32_t logger_lock_ctr; /* how many times has logger lock been taken/released */
u_int32_t checkpoint_period; /* delay between automatic checkpoints */ u_int32_t checkpoint_period; /* delay between automatic checkpoints */
u_int32_t checkpoint_footprint; /* state of checkpoint procedure */ u_int32_t checkpoint_footprint; /* state of checkpoint procedure */
char checkpoint_time_begin[26]; /* time of last checkpoint begin */ char checkpoint_time_begin[26]; /* time of last checkpoint begin */
......
...@@ -8,12 +8,17 @@ ...@@ -8,12 +8,17 @@
static const int log_format_version=TOKU_LOG_VERSION; static const int log_format_version=TOKU_LOG_VERSION;
static toku_pthread_mutex_t logger_mutex = TOKU_PTHREAD_MUTEX_INITIALIZER; static toku_pthread_mutex_t logger_mutex = TOKU_PTHREAD_MUTEX_INITIALIZER;
static u_int32_t logger_lock_ctr = 0; // useful for debug at a live installation
static int (*toku_os_fsync_function)(int)=fsync; static int (*toku_os_fsync_function)(int)=fsync;
static int open_logfile (TOKULOGGER logger); static int open_logfile (TOKULOGGER logger);
static int delete_logfile(TOKULOGGER logger, long long index); static int delete_logfile(TOKULOGGER logger, long long index);
static int do_write (TOKULOGGER logger, int do_fsync); static int do_write (TOKULOGGER logger, int do_fsync);
u_int32_t toku_logger_get_lock_ctr(void) {
return logger_lock_ctr;
}
int toku_logger_create (TOKULOGGER *resultp) { int toku_logger_create (TOKULOGGER *resultp) {
int r; int r;
TAGMALLOC(TOKULOGGER, result); TAGMALLOC(TOKULOGGER, result);
...@@ -139,6 +144,7 @@ int toku_logger_close(TOKULOGGER *loggerp) { ...@@ -139,6 +144,7 @@ int toku_logger_close(TOKULOGGER *loggerp) {
r = ml_lock(&logger->output_lock); if (r!=0) goto panic; r = ml_lock(&logger->output_lock); if (r!=0) goto panic;
r = ml_lock(&logger->input_lock); if (r!=0) goto panic; r = ml_lock(&logger->input_lock); if (r!=0) goto panic;
r = toku_pthread_mutex_lock(&logger_mutex); if (r!=0) goto panic; r = toku_pthread_mutex_lock(&logger_mutex); if (r!=0) goto panic;
logger_lock_ctr++;
locked_logger = 1; locked_logger = 1;
r = do_write(logger, 1); if (r!=0) goto panic; //Releases the input lock r = do_write(logger, 1); if (r!=0) goto panic; //Releases the input lock
if (logger->fd!=-1) { if (logger->fd!=-1) {
...@@ -157,6 +163,7 @@ int toku_logger_close(TOKULOGGER *loggerp) { ...@@ -157,6 +163,7 @@ int toku_logger_close(TOKULOGGER *loggerp) {
toku_free(logger); toku_free(logger);
*loggerp=0; *loggerp=0;
if (locked_logger) { if (locked_logger) {
logger_lock_ctr++;
r = toku_pthread_mutex_unlock(&logger_mutex); if (r!=0) goto panic; r = toku_pthread_mutex_unlock(&logger_mutex); if (r!=0) goto panic;
} }
return r; return r;
...@@ -247,6 +254,7 @@ int toku_logger_set_lg_bsize(TOKULOGGER logger, u_int32_t bsize) { ...@@ -247,6 +254,7 @@ int toku_logger_set_lg_bsize(TOKULOGGER logger, u_int32_t bsize) {
int toku_logger_lock_init(void) { int toku_logger_lock_init(void) {
int r = toku_pthread_mutex_init(&logger_mutex, NULL); int r = toku_pthread_mutex_init(&logger_mutex, NULL);
logger_lock_ctr = 0;
assert(r == 0); assert(r == 0);
return r; return r;
} }
......
...@@ -13,6 +13,8 @@ int toku_logger_log_bytes (TOKULOGGER logger, struct logbytes *bytes, int do_fsy ...@@ -13,6 +13,8 @@ int toku_logger_log_bytes (TOKULOGGER logger, struct logbytes *bytes, int do_fsy
int toku_logger_shutdown(TOKULOGGER logger); int toku_logger_shutdown(TOKULOGGER logger);
int toku_logger_close(TOKULOGGER *loggerp); int toku_logger_close(TOKULOGGER *loggerp);
u_int32_t toku_logger_get_lock_ctr(void);
int toku_logger_fsync (TOKULOGGER logger); int toku_logger_fsync (TOKULOGGER logger);
void toku_logger_panic (TOKULOGGER logger, int err); void toku_logger_panic (TOKULOGGER logger, int err);
int toku_logger_panicked(TOKULOGGER logger); int toku_logger_panicked(TOKULOGGER logger);
......
...@@ -988,7 +988,8 @@ env_get_engine_status(DB_ENV * env, ENGINE_STATUS * engstat) { ...@@ -988,7 +988,8 @@ env_get_engine_status(DB_ENV * env, ENGINE_STATUS * engstat) {
else { else {
time_t now = time(NULL); time_t now = time(NULL);
format_time(&now, engstat->now); format_time(&now, engstat->now);
engstat->ydb_lock_ctr = toku_ydb_lock_ctr(); // is ydb lock held? how many times? engstat->ydb_lock_ctr = toku_ydb_lock_ctr(); // is ydb lock held? how many times taken/released?
engstat->logger_lock_ctr = toku_logger_get_lock_ctr(); // is logger lock held? how many times taken/released?
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) 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)
{ {
CHECKPOINT_STATUS_S cpstat; CHECKPOINT_STATUS_S cpstat;
......
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