INTERNAL: Converted the cmdlog file storage scheme#963
INTERNAL: Converted the cmdlog file storage scheme#963namsic merged 1 commit intonaver:kafka-pocfrom
Conversation
| } | ||
|
|
||
| logbuff->fque[logbuff->fend].nflush += spare_length; | ||
| logger->log(EXTENSION_LOG_INFO, NULL, "[DEBUG] nflush = %d\n", logbuff->fque[logbuff->fend].nflush); |
There was a problem hiding this comment.
전체적으로 DEBUG 로그를 INFO 레벨로 기록하고 있어서 정리가 필요합니다.
jhpark816
left a comment
There was a problem hiding this comment.
일부 리뷰.
Offline으로 추가 의견을 전달할게요.
4ff229a to
4724d85
Compare
296d0e8 to
87e2429
Compare
|
logfile 관리 방식, |
|
|
||
| #define MAX_FILE_SIZE (4 * 1024) //1024*1024*1024 // 1GB /* unit : byte */ | ||
|
|
There was a problem hiding this comment.
외부에서 가져다 사용하기 위한 값이 아니라서 cmdlogfile.c에 두어도 될 것 같은데, 어떤가요?
There was a problem hiding this comment.
cmdlogfile.c에 두는 것이 맞다고 생각합니다.
|
|
||
| /* start the snapshot thread */ | ||
| ss->running = true; | ||
| //ss->running = true; |
There was a problem hiding this comment.
do_snapshot_thread_main()을 통해 실행되는 함수 중 do_snapshot_direct() 함수에서 수행하기 때문입니다.
| bool cmdlog_file_deletable() { | ||
| bool ret; | ||
| pthread_mutex_lock(&log_file_gl.file_access_lock); | ||
| ret = log_buff_gl.fidx_bgn < log_file_gl.fidx_end; | ||
| pthread_mutex_unlock(&log_file_gl.file_access_lock); | ||
| return ret; | ||
| } |
There was a problem hiding this comment.
아래 확인해 주세요.
engines/default/cmdlogfile.c:64:6: error: no previous prototype for 'cmdlog_file_deletable' [-Werror=missing-prototypes]
64 | bool cmdlog_file_deletable() {
| ^~~~~~~~~~~~~~~~~~~~~
engines/default/cmdlogfile.c: In function 'cmdlog_file_deletable':
engines/default/cmdlogfile.c:67:11: error: 'log_buff_gl' undeclared (first use in this function)
67 | ret = log_buff_gl.fidx_bgn < log_file_gl.fidx_end;
| ^~~~~~~~~~~
There was a problem hiding this comment.
cmdlog_file_deletable()의 프로토타입을 cmdlogfile.h에 작성하여 다시 올렸습니다.
|
@podongpodong |
|
|
코멘트 내용 반영하여 수정했습니다. |
443acab to
33677a7
Compare
| else if (memcmp(modestr, "snapshot", 8) == 0) { | ||
| CHECK_NTOKENS_EQ(ntokens, 4); | ||
| filepath = NULL; | ||
| } |
There was a problem hiding this comment.
@podongpodong
질문이 있습니다.
snapshot 수행 시에 filepath 지정 여부를 검토해 볼 수 있는 데,
어떤 방식이 현재의 snapshot 수행에 더 적합한가요?
- filepath 지장하는 방식
- filepath 지정하지 않는 방식
There was a problem hiding this comment.
- 현재 코드에서는 filepath를 지정하는 방식이 적합하다고 생각합니다.
dump start snapshot을 통해 실행되는chkpt_snapshot()의 동작 흐름에서 snapshot_<time>, cmdlog_<time>_<number> 형식의 파일 생성을 하고 있습니다.- 현재 producer는 스냅샷 파일이 config 파일에 설정한 data_path 경로에 snapshot_의 형식으로 저장된다는 전제로 동작하고 있습니다.
- filepath를 지정해서 snapshot을 하는 경우 produce를 위해서 경로 제약, 파일 형식 제약이 별도로 필요해집니다.
There was a problem hiding this comment.
@podongpodong @namsic
persistence 관련된 data_path와 logs_path는 persistence 기능에서 사용해야 합니다.
persistence 기능이 동작하는 상태에서 데이터 동기화를 CDC 작업을 수행할 수 있으므로,
CDC를 위한 snapshot과 log file들은 별도로 지정하는 것이 좋겠습니다.
| if (ret != ENGINE_SUCCESS) { | ||
| dumper->running = false; | ||
| } | ||
| dumper->running = false; |
There was a problem hiding this comment.
@podongpodong
dumper->running = false 설정하는 이유는 무엇인가요?
There was a problem hiding this comment.
dump start snapshot에 동작을 수정하면서 콜백으로 설정한 item_dumper_done가 수행되지 않기 때문에 chkpt_snapshot_start이후 쓰레드를 종료하기 위함입니다.
| char *modestr = NULL; | ||
| char *filepath = NULL; |
| { | ||
| log_FILE *logfile = &log_file_gl.log_file; | ||
| int fd, ret = 0; | ||
|
|
There was a problem hiding this comment.
#964 에서 함께 수정하거나, 기존 구현 유지하는 것이 좋겠습니다.
빈 line으로 구분하는 기존 구현이 나아 보입니다.
상단의 /* fsync curr fd */ 주석 제거는 로직 변경과 관련 있어서 제거한 것인가요?
There was a problem hiding this comment.
기존 구현 유지하겠습니다.
/* fsync curr fd */ 주석은 코드 변경 중에 잘못 제거되었습니다.
90d6529 to
e83258c
Compare
|
|
e83258c to
00b3dfd
Compare
|
Consumer에서 발생하던 병목 현상을 개선했습니다. 병목 원인의 확인은 아래의 명령어를 통해서 확인했습니다.
|
a7ef48c to
464ab55
Compare
|
Persistence와 CDC 분리한 상태로 테스트 했고 produce하면서 주기적으로 checkpoint 동작하는 것을 확인했습니다.
|
464ab55 to
edbc6e4
Compare
edbc6e4 to
202e916
Compare
🔗 Related Issue
⌨️ What I did
기존의 구현
snapshot_<time>cmdlog_<time>형식을 사용합니다.cmdlog_file_sync()에서 prev_fd에 대한 fsync() 후 close()를 합니다.cmdlog_file_complete_dual_write()후 바로 prev_fd를 close()합니다.chkpt_thread_main에서 주기적으로 실행합니다.변경한 구현
로그 파일의 크기에 따라서 자동으로 체크포인트가 수행되는
chkpt_thread_main()의 동작을 비활성화 시켰습니다.dump start snapshot을 통해 실행되는 체크포인트는do_snapshot_thread_main()으로 수행하도록 로직을 변경했습니다.하나의 snapshot, 최대 크기를 제한한 로그 파일을 큐 형태로 연결하여 관리합니다.
snapshot_<time>,snapshot_<time>_<number>형식을 사용합니다.<number>는<time>에 해당하는 snapshot 이후로 생성된 몇번 째 로그 파일인지를 나타냅니다.로그 파일을 전역으로 관리하는
log_file_global구조체와 구조체의 필드인logFILE구조체를 변형했습니다.<number>의 시작과 끝을 관리합니다.체크포인팅 이후 기존 로그 파일을 생성하는 로직을 변경했습니다.
Producer 쓰레드를 구현했습니다.
Cosumer 프로세스를 구현했습니다.
gcc consumer.c util.c -I./include -o consumer -lrdkafka -lmemcached를 통해서 컴파일 가능합니다.