sf_binlog_writer_rotate_file can skip empty file
parent
e9e33883bf
commit
14a783fd6f
|
|
@ -168,6 +168,7 @@ static int deal_binlog_records(SFBinlogWriterThread *thread,
|
||||||
SFBinlogWriterBuffer *wb_head, uint32_t *last_timestamp)
|
SFBinlogWriterBuffer *wb_head, uint32_t *last_timestamp)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
|
bool skip_empty_file;
|
||||||
SFBinlogWriterBuffer *wbuffer;
|
SFBinlogWriterBuffer *wbuffer;
|
||||||
SFBinlogWriterBuffer *current;
|
SFBinlogWriterBuffer *current;
|
||||||
|
|
||||||
|
|
@ -196,11 +197,14 @@ static int deal_binlog_records(SFBinlogWriterThread *thread,
|
||||||
thread->mblock, current);
|
thread->mblock, current);
|
||||||
break;
|
break;
|
||||||
case SF_BINLOG_BUFFER_TYPE_ROTATE_FILE:
|
case SF_BINLOG_BUFFER_TYPE_ROTATE_FILE:
|
||||||
if ((result=sf_file_writer_set_binlog_write_index(¤t->
|
skip_empty_file = current->version.first;
|
||||||
writer->fw, current->writer->fw.binlog.
|
if (!(skip_empty_file && current->writer->fw.file.size == 0)) {
|
||||||
last_index + 1)) != 0)
|
if ((result=sf_file_writer_set_binlog_write_index(¤t->
|
||||||
{
|
writer->fw, current->writer->fw.binlog.
|
||||||
return result;
|
last_index + 1)) != 0)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fast_mblock_free_object(¤t->writer->
|
fast_mblock_free_object(¤t->writer->
|
||||||
thread->mblock, current);
|
thread->mblock, current);
|
||||||
|
|
@ -623,10 +627,12 @@ int sf_binlog_writer_change_write_index(SFBinlogWriterInfo *writer,
|
||||||
SF_BINLOG_BUFFER_TYPE_SET_WRITE_INDEX, write_index);
|
SF_BINLOG_BUFFER_TYPE_SET_WRITE_INDEX, write_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
int sf_binlog_writer_rotate_file(SFBinlogWriterInfo *writer)
|
int sf_binlog_writer_rotate_file_ex(SFBinlogWriterInfo *writer,
|
||||||
|
const bool skip_empty_file)
|
||||||
{
|
{
|
||||||
return sf_binlog_writer_push_directive(writer,
|
return sf_binlog_writer_push_directive(writer,
|
||||||
SF_BINLOG_BUFFER_TYPE_ROTATE_FILE, 0);
|
SF_BINLOG_BUFFER_TYPE_ROTATE_FILE,
|
||||||
|
skip_empty_file ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int sf_binlog_writer_flush_file(SFBinlogWriterInfo *writer)
|
int sf_binlog_writer_flush_file(SFBinlogWriterInfo *writer)
|
||||||
|
|
|
||||||
|
|
@ -235,7 +235,14 @@ static inline int sf_binlog_writer_get_thread_waiting_count(
|
||||||
return waiting_count;
|
return waiting_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sf_binlog_writer_rotate_file(SFBinlogWriterInfo *writer);
|
int sf_binlog_writer_rotate_file_ex(SFBinlogWriterInfo *writer,
|
||||||
|
const bool skip_empty_file);
|
||||||
|
|
||||||
|
static inline int sf_binlog_writer_rotate_file(SFBinlogWriterInfo *writer)
|
||||||
|
{
|
||||||
|
const bool skip_empty_file = false;
|
||||||
|
return sf_binlog_writer_rotate_file_ex(writer, skip_empty_file);
|
||||||
|
}
|
||||||
|
|
||||||
int sf_binlog_writer_flush_file(SFBinlogWriterInfo *writer);
|
int sf_binlog_writer_flush_file(SFBinlogWriterInfo *writer);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue