@@ -436,7 +436,7 @@ int Segment::append(const LogEntry* entry) {
436436 return 0 ;
437437}
438438
439- int Segment::sync (bool will_sync) {
439+ int Segment::sync (bool will_sync, bool has_conf ) {
440440 if (_last_index < _first_index) {
441441 return 0 ;
442442 }
@@ -446,7 +446,8 @@ int Segment::sync(bool will_sync) {
446446 return 0 ;
447447 }
448448 if (FLAGS_raft_sync_policy == RaftSyncPolicy::RAFT_SYNC_BY_BYTES
449- && FLAGS_raft_sync_per_bytes > _unsynced_bytes) {
449+ && FLAGS_raft_sync_per_bytes > _unsynced_bytes
450+ && !has_conf) {
450451 return 0 ;
451452 }
452453 _unsynced_bytes = 0 ;
@@ -737,6 +738,7 @@ int SegmentLogStorage::append_entries(const std::vector<LogEntry*>& entries, IOM
737738 scoped_refptr<Segment> last_segment = NULL ;
738739 int64_t now = 0 ;
739740 int64_t delta_time_us = 0 ;
741+ bool has_conf = false ;
740742 for (size_t i = 0 ; i < entries.size (); i++) {
741743 now = butil::cpuwide_time_us ();
742744 LogEntry* entry = entries[i];
@@ -754,6 +756,9 @@ int SegmentLogStorage::append_entries(const std::vector<LogEntry*>& entries, IOM
754756 if (0 != ret) {
755757 return i;
756758 }
759+ if (entry->type == ENTRY_TYPE_CONFIGURATION) {
760+ has_conf = true ;
761+ }
757762 if (FLAGS_raft_trace_append_entry_latency && metric) {
758763 delta_time_us = butil::cpuwide_time_us () - now;
759764 metric->append_entry_time_us += delta_time_us;
@@ -763,7 +768,7 @@ int SegmentLogStorage::append_entries(const std::vector<LogEntry*>& entries, IOM
763768 last_segment = segment;
764769 }
765770 now = butil::cpuwide_time_us ();
766- last_segment->sync (_enable_sync);
771+ last_segment->sync (_enable_sync, has_conf );
767772 if (FLAGS_raft_trace_append_entry_latency && metric) {
768773 delta_time_us = butil::cpuwide_time_us () - now;
769774 metric->sync_segment_time_us += delta_time_us;
0 commit comments