Skip to content

Commit

Permalink
redo logging nvdimm 170823
Browse files Browse the repository at this point in the history
  • Loading branch information
JonghyeokPark committed Aug 23, 2017
1 parent df9a1d8 commit 0a2ac59
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 19 deletions.
3 changes: 2 additions & 1 deletion storage/innobase/buf/buf0flu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1037,8 +1037,9 @@ buf_flush_write_block_low(

/* Force the log to the disk before writing the modified block */
if (!srv_read_only_mode) {
//fprintf(stderr,"[JONGQ] buf0buf log_write_up_to call!\n");
fprintf(stderr,"[JONGQ] buf_flush_write_block_low() log_write_up_to call!\n");
log_write_up_to(bpage->newest_modification, true);
fprintf(stderr,"[JONGQ] buf_flush_write_block_low() log_write_up_to call FINISH!\n");
}

switch (buf_page_get_state(bpage)) {
Expand Down
37 changes: 27 additions & 10 deletions storage/innobase/log/log0log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ the previous */
#define LOG_UNLOCK_FLUSH_LOCK 2

/* JONGQ */
bool PRIMAL_FLAG=false;
bool PRIMAL_FLAG=false; // 체크포인트 혹은 서버 Shutdown 과정에서 강제로 로그에 쓰도록 하는 과정
bool FLUSH_FLAG=false; // checkBufHalf()가 통과한 경우에만 처리하도록
bool SHUTDOWN_FLAG=false; // 데이터베이스 종료시 log file 쓰도록
bool checkBufHalf(void){
if(log_sys->buf_free > log_sys->buf_size/2){
fprintf(stderr,"[JONGQ] TRUE buf_free: %lu \t buf_size: %lu \n",log_sys->buf_free,log_sys->buf_size);
Expand Down Expand Up @@ -1058,7 +1060,6 @@ log_group_write_buf(
if we have to write a new log file
header */
{
//fprintf(stderr,"[JONGQ] log_group_write_buf CALL!\n");

ulint write_len;
bool write_header = new_data_offset == 0;
Expand All @@ -1071,6 +1072,7 @@ log_group_write_buf(
ut_a(start_lsn % OS_FILE_LOG_BLOCK_SIZE == 0);

loop:

if (len == 0) {

return;
Expand Down Expand Up @@ -1141,16 +1143,18 @@ log_group_write_buf(
= (ulint) (next_offset / univ_page_size.physical());

// JONGQ Check this one!
if(checkBufHalf() || PRIMAL_FLAG){
// vesrion#2 occur deadlock ...
//if(checkBufHalf() || PRIMAL_FLAG){

fprintf(stderr,"[JONGQ] fil_io call! write_len: %ul\n",write_len);
fil_io(IORequestLogWrite, true,
page_id_t(group->space_id, page_no),
univ_page_size,
(ulint) (next_offset % UNIV_PAGE_SIZE), write_len, buf,
group);

PRIMAL_FLAG=false;
}
// FLUSH_FLAG=true;
// PRIMAL_FLAG=false;
//}
//fprintf(stderr,"[JONGQ] fil_io call! size: %lu\n",write_len);

srv_stats.os_log_pending_writes.dec();
Expand Down Expand Up @@ -1255,6 +1259,13 @@ log_write_up_to(
return;
}

if(checkBufHalf() || PRIMAL_FLAG || SHUTDOWN_FLAG)
goto loop;
else{
fprintf(stderr,"[JONGQ] NOT NOW in log_write_up_to()\n");
return;
}

loop:
ut_ad(++loop_count < 128);

Expand Down Expand Up @@ -1413,7 +1424,8 @@ log_write_up_to(
ORIGINAL : CLEAR if
*/
//if(checkBufHalf() || PRIMAL_FLAG){
//fprintf(stderr,"[JONGQ] log_group_write_buf call!\n");
fprintf(stderr,"[JONGQ] log_group_write_buf call!\n");

log_group_write_buf(
group, write_buf + area_start,
area_end - area_start + pad_size,
Expand All @@ -1423,7 +1435,6 @@ log_write_up_to(
ut_uint64_align_down(log_sys->write_lsn,
OS_FILE_LOG_BLOCK_SIZE),
start_offset - area_start);

// PRIMAL_FLAG=false;
//}

Expand All @@ -1441,7 +1452,7 @@ log_write_up_to(

log_write_mutex_exit();

if (flush_to_disk) {
if (flush_to_disk){
log_write_flush_to_disk_low();
}
}
Expand Down Expand Up @@ -1482,6 +1493,7 @@ log_buffer_sync_in_background(
}

log_mutex_exit();
fprintf(stderr,"[JONGQ] log_buffer_sycn_in_background() call log_write_up_to!\n");
log_write_up_to(lsn, flush);
}

Expand All @@ -1506,6 +1518,7 @@ log_flush_margin(void)

log_mutex_exit();
if (lsn) {
fprintf(stderr,"[JONGQ] log_flush_margin() call log_write_up_to!\n");
log_write_up_to(lsn, false);
}
}
Expand Down Expand Up @@ -1877,8 +1890,12 @@ log_checkpoint(
}

log_mutex_exit();

fprintf(stderr,"[JONGQ] log_checkpoint call log_write_up_to\n");
if(SHUTDOWN_FLAG == true){
fprintf(stderr,"[JONGQ] PRIMAL_FLAG is TRUE when calling log_checkpoint\n");
}

//fprintf(stderr,"[JONGQ] log_checkpoint call log_write_up_to\n");
log_write_up_to(flush_lsn, true);

DBUG_EXECUTE_IF(
Expand Down
19 changes: 13 additions & 6 deletions storage/innobase/srv/srv0srv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2152,15 +2152,21 @@ srv_master_do_active_tasks(void)
}

/* Make a new checkpoint */

if (cur_time % SRV_MASTER_CHECKPOINT_INTERVAL == 0) {
srv_main_thread_op_info = "making checkpoint";

//fprintf(stderr,"[JONGQ] srv_master_active call log_checkpoint!\n");

fprintf(stderr,"[JONGQ] srv_master_active call log_checkpoint!\n");
// JONGQ ADDED
extern bool PRIMAL_FLAG;
PRIMAL_FLAG=true;
log_checkpoint(TRUE, FALSE);
PRIMAL_FLAG=false;

MONITOR_INC_TIME_IN_MICRO_SECS(
MONITOR_SRV_CHECKPOINT_MICROSECOND, counter_time);
}

}

/*********************************************************************//**
Expand Down Expand Up @@ -2299,11 +2305,12 @@ srv_master_do_shutdown_tasks(
/* Make a new checkpoint about once in 10 seconds */
srv_main_thread_op_info = "making checkpoint";

//fprintf(stderr,"[JONGQ] srv_master_shutdown call log_checkpoint!\n");
extern bool PRIMAL_FLAG;
PRIMAL_FLAG=true;
fprintf(stderr,"[JONGQ] srv_master_shutdown call log_checkpoint!\n");
//extern bool PRIMAL_FLAG;
//PRIMAL_FLAG=true;
extern bool SHUTDOWN_FLAG;
SHUTDOWN_FLAG = true;
log_checkpoint(TRUE, FALSE);
PRIMAL_FLAG=false;

/* Print progress message every 60 seconds during shutdown */
if (srv_shutdown_state > 0 && srv_print_verbose_log) {
Expand Down
8 changes: 7 additions & 1 deletion storage/innobase/srv/srv0start.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1388,7 +1388,12 @@ srv_prepare_to_delete_redo_log_files(
/* Flush the old log files. */
log_mutex_exit();

// JONGQ flsuh log @ start
fprintf(stderr,"[JONGQ] srv_prepare_to_delete_redo_log_files CALL!\n");
extern bool PRIMAL_FLAG;
PRIMAL_FLAG=true;
log_write_up_to(flushed_lsn, true);
PRIMAL_FLAG=false;

/* If innodb_flush_method=O_DSYNC,
we need to explicitly flush the log buffers. */
Expand Down Expand Up @@ -2220,7 +2225,6 @@ innobase_start_or_create_for_mysql(void)

/* We always try to do a recovery, even if the database had
been shut down normally: this is the normal startup path */

err = recv_recovery_from_checkpoint_start(flushed_lsn);

recv_sys->dblwr.pages.clear();
Expand Down Expand Up @@ -2661,6 +2665,8 @@ innobase_start_or_create_for_mysql(void)
os_thread_create(buf_resize_thread, NULL, NULL);

srv_was_started = TRUE;

fprintf(stderr,"[JONGQ] server setting finish?\n");
return(DB_SUCCESS);
}

Expand Down
2 changes: 1 addition & 1 deletion storage/innobase/trx/trx0trx.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1786,7 +1786,7 @@ trx_flush_log_if_needed_low(
/* fall through */
case 1:
/* Write the log and optionally flush it to disk */
//fprintf(stderr,"[JONGQ] trx_flush_log_if_neede_low call log_write_up_to()\n");
fprintf(stderr,"[JONGQ] trx_flush_log_if_neede_low call log_write_up_to()\n");
log_write_up_to(lsn, flush);
return;
case 0:
Expand Down

0 comments on commit 0a2ac59

Please sign in to comment.