vamossagar12 commented on pull request #10278:
URL: https://github.com/apache/kafka/pull/10278#issuecomment-850068544


   @jsancio , yeah would do that. Actually I have a question here. I didn't get 
a chance to look at this PR for some time and now i see things have changed 
which impacts my implementation strategy.
   
   In the older versions, there used to be a direct flushLeaderLog() call from 
appendLeaderChangeMessage. This is the older version:
   
   ```
       private void appendLeaderChangeMessage(LeaderState state, long 
baseOffset, long currentTimeMs) {
           List<Voter> voters = convertToVoters(state.followers());
           List<Voter> grantingVoters = convertToVoters(state.grantingVoters());
   
           // Adding the leader to the voters as any voter always votes for 
itself.
           voters.add(new Voter().setVoterId(state.election().leaderId()));
   
           LeaderChangeMessage leaderChangeMessage = new LeaderChangeMessage()
               .setLeaderId(state.election().leaderId())
               .setVoters(voters)
               .setGrantingVoters(grantingVoters);
   
           MemoryRecords records = MemoryRecords.withLeaderChangeMessage(
               baseOffset,
               currentTimeMs,
               quorum.epoch(),
               leaderChangeMessage
           );
   
           appendAsLeader(records);
           // For a LeaderChange message, flushLeaderLogOnHwmUpdate is set to 
false
           // as we have to flush the log irrespective of whether the HWM moved 
or not.
           flushLeaderLog(state, currentTimeMs, false);
       }
   
   ```
   I had added a parameter called `flushLeaderLogOnHwmUpdate` to flushLeaderLog 
which indicated if the flush depended upon HWM moving or not. For the case of 
control record it didn't so false was passed which indicates explicit flush 
while from `mayBeAppendBatched` true was passed which would ensure deferral. 
   
   In the latest version of KafkaRaftClient, I see that the explicit flush has 
been removed and instead LeaderState does a force drain. That ensures that 
there's only 1 place needed for flushLeaderLog().
   Now my doubt is, I can't add the fsync deferral logic directly over there as 
now it can have records which need explicit fsyncing - like control records. 
So, how do i segregate between the 2?
   
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to