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;
|
adheader = (SFProtoIdempotencyAdditionalHeader *)req->body;
|
||||||
request = (IdempotencyRequest *)fast_mblock_alloc_object(request_allocator);
|
request = fast_mblock_alloc_object(request_allocator);
|
||||||
if (request == NULL) {
|
if (request == NULL) {
|
||||||
*result = ENOMEM;
|
*result = ENOMEM;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
||||||
|
|
@ -217,11 +217,13 @@ static int deal_binlog_records(SFBinlogWriterThread *thread,
|
||||||
return ERRNO_THREAD_EXIT;
|
return ERRNO_THREAD_EXIT;
|
||||||
case SF_BINLOG_BUFFER_TYPE_SET_NEXT_VERSION:
|
case SF_BINLOG_BUFFER_TYPE_SET_NEXT_VERSION:
|
||||||
if (current->writer->order_by !=
|
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, "
|
logWarning("file: "__FILE__", line: %d, "
|
||||||
"subdir_name: %s, invalid order by: %d != %d, "
|
"subdir_name: %s, order by: %d != %d, "
|
||||||
"maybe some mistake happen", __LINE__,
|
"maybe some mistake happen?", __LINE__,
|
||||||
current->writer->fw.cfg.subdir_name,
|
current->writer->fw.cfg.subdir_name,
|
||||||
current->writer->order_by,
|
current->writer->order_by,
|
||||||
SF_BINLOG_WRITER_TYPE_ORDER_BY_VERSION);
|
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,
|
__LINE__, current->writer->fw.cfg.subdir_name,
|
||||||
current->version.first);
|
current->version.first);
|
||||||
|
|
||||||
if (current->writer->version_ctx.next !=
|
if ((current->writer->order_by ==
|
||||||
current->version.first)
|
SF_BINLOG_WRITER_TYPE_ORDER_BY_NONE) ||
|
||||||
|
(current->writer->version_ctx.next !=
|
||||||
|
current->version.first))
|
||||||
{
|
{
|
||||||
binlog_writer_set_next_version(current->writer,
|
binlog_writer_set_next_version(current->writer,
|
||||||
current->version.first);
|
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,
|
#define SF_REPLICATION_QUORUM_MAJORITY(server_count, success_count) \
|
||||||
const int total_count, const int active_slave_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) {
|
switch (quorum) {
|
||||||
case sf_replication_quorum_any:
|
case sf_replication_quorum_any:
|
||||||
return true;
|
return true;
|
||||||
case sf_replication_quorum_auto:
|
case sf_replication_quorum_auto:
|
||||||
if (total_count % 2 == 0) {
|
if (server_count % 2 == 0) {
|
||||||
return true; //same as sf_replication_quorum_any
|
return true; //same as sf_replication_quorum_any
|
||||||
}
|
}
|
||||||
//continue
|
//continue
|
||||||
case sf_replication_quorum_majority:
|
case sf_replication_quorum_majority:
|
||||||
if ((active_slave_count + 1) == total_count) {
|
return SF_REPLICATION_QUORUM_MAJORITY(
|
||||||
return true;
|
server_count, success_count);
|
||||||
} else {
|
|
||||||
return (active_slave_count + 1) > total_count / 2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue