Description
There is a race condition between the highwatermark thread and the handleLeaderAndIsrRequest call of the request handler thread. When a broker starts, the highwatermark thread tries to persist all the checkpoints of the partitions in ReplicaManager. This partition map in ReplicaManager is initially empty. When the leaderAndIsrRequest runs, it updates each partition and if the highwatermark thread runs during this interval, it is essentially going to overwrite the highwatermark file to an inconsistent state. The read of the highwatermark reads from the file each time and hence would return the inconsistent state.