[persistence] fix error at first checkpoint
@@ -450,6 +450,14 @@ void cmdlog_complete_dual_write(bool success)
log_BUFFER *logbuff = &log_gl.log_buffer;
pthread_mutex_lock(&log_gl.log_flush_lock);
+ do {
+ if (log_gl.log_file.next_fd == -1) {
+ /* next_fd == -1 means the first state without log file.
+ * created first log file by checkpoint.
+ * do not cleanup file fds.
+ */
+ break;
+ }
if (success) {
pthread_mutex_lock(&log_gl.log_write_lock);
if (logbuff->fque[logbuff->fend].nflush > 0) {
@@ -484,6 +492,7 @@ void cmdlog_complete_dual_write(bool success)
log_gl.log_file.prev_fd = log_gl.log_file.next_fd;
log_gl.log_file.next_fd = -1;
}
+ } while(0);
pthread_mutex_unlock(&log_gl.log_flush_lock);
}
