support set next version when order_mode is VARY
parent
22ffe6841d
commit
7f7ba8d835
|
|
@ -189,7 +189,7 @@ IdempotencyRequest *sf_server_update_prepare_and_check(
|
|||
}
|
||||
|
||||
adheader = (SFProtoIdempotencyAdditionalHeader *)req->body;
|
||||
request = (IdempotencyRequest *)fast_mblock_alloc_object(request_allocator);
|
||||
request = fast_mblock_alloc_object(request_allocator);
|
||||
if (request == NULL) {
|
||||
*result = ENOMEM;
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -217,11 +217,13 @@ static int deal_binlog_records(SFBinlogWriterThread *thread,
|
|||
return ERRNO_THREAD_EXIT;
|
||||
case SF_BINLOG_BUFFER_TYPE_SET_NEXT_VERSION:
|
||||
if (current->writer->order_by !=
|
||||
SF_BINLOG_WRITER_TYPE_ORDER_BY_VERSION)
|
||||
SF_BINLOG_WRITER_TYPE_ORDER_BY_VERSION &&
|
||||
current->writer->thread->order_mode !=
|
||||
SF_BINLOG_THREAD_ORDER_MODE_VARY)
|
||||
{
|
||||
logWarning("file: "__FILE__", line: %d, "
|
||||
"subdir_name: %s, invalid order by: %d != %d, "
|
||||
"maybe some mistake happen", __LINE__,
|
||||
"subdir_name: %s, order by: %d != %d, "
|
||||
"maybe some mistake happen?", __LINE__,
|
||||
current->writer->fw.cfg.subdir_name,
|
||||
current->writer->order_by,
|
||||
SF_BINLOG_WRITER_TYPE_ORDER_BY_VERSION);
|
||||
|
|
@ -239,8 +241,10 @@ static int deal_binlog_records(SFBinlogWriterThread *thread,
|
|||
__LINE__, current->writer->fw.cfg.subdir_name,
|
||||
current->version.first);
|
||||
|
||||
if (current->writer->version_ctx.next !=
|
||||
current->version.first)
|
||||
if ((current->writer->order_by ==
|
||||
SF_BINLOG_WRITER_TYPE_ORDER_BY_NONE) ||
|
||||
(current->writer->version_ctx.next !=
|
||||
current->version.first))
|
||||
{
|
||||
binlog_writer_set_next_version(current->writer,
|
||||
current->version.first);
|
||||
|
|
|
|||
|
|
@ -142,23 +142,23 @@ static inline const char *sf_get_replication_quorum_caption(
|
|||
}
|
||||
}
|
||||
|
||||
static inline bool sf_replication_quorum_check(const SFReplicationQuorum quorum,
|
||||
const int total_count, const int active_slave_count)
|
||||
#define SF_REPLICATION_QUORUM_MAJORITY(server_count, success_count) \
|
||||
((success_count == server_count) || (success_count > server_count / 2))
|
||||
|
||||
static inline bool sf_replication_quorum_check(const SFReplicationQuorum
|
||||
quorum, const int server_count, const int success_count)
|
||||
{
|
||||
switch (quorum) {
|
||||
case sf_replication_quorum_any:
|
||||
return true;
|
||||
case sf_replication_quorum_auto:
|
||||
if (total_count % 2 == 0) {
|
||||
if (server_count % 2 == 0) {
|
||||
return true; //same as sf_replication_quorum_any
|
||||
}
|
||||
//continue
|
||||
case sf_replication_quorum_majority:
|
||||
if ((active_slave_count + 1) == total_count) {
|
||||
return true;
|
||||
} else {
|
||||
return (active_slave_count + 1) > total_count / 2;
|
||||
}
|
||||
return SF_REPLICATION_QUORUM_MAJORITY(
|
||||
server_count, success_count);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue