Hi:
    I am engineer from China, I review kafka mirror latest impl, but I do
not figure out the reason why PartitionState update like that:
```

    // true if we should emit an offset sync
    boolean update(long upstreamOffset, long downstreamOffset) {
        boolean shouldSyncOffsets = false;
        long upstreamStep = upstreamOffset - lastSyncUpstreamOffset;
        long downstreamTargetOffset = lastSyncDownstreamOffset + upstreamStep;
        if (lastSyncDownstreamOffset == -1L
                || downstreamOffset - downstreamTargetOffset >= maxOffsetLag
                || upstreamOffset - previousUpstreamOffset != 1L
                || downstreamOffset < previousDownstreamOffset) {
            lastSyncUpstreamOffset = upstreamOffset;
            lastSyncDownstreamOffset = downstreamOffset;
            shouldSyncOffsets = true;
        }
        previousUpstreamOffset = upstreamOffset;
        previousDownstreamOffset = downstreamOffset;
        return shouldSyncOffsets;
    }
}

```
I can not know why the condition is like that.
1. lastSyncDownstreamOffset == -1L: never sync, so call sync method
2. downstreamOffset - downstreamTargetOffset >= maxOffsetLag: offset is not
accurate, so sync. but why use maxOffsetLag? why not >0: meaning not
accurate
3. upstreamOffset - previousUpstreamOffset != 1L: meaning why?
4. downstreamOffset < previousDownstreamOffset: meaning why?

Reply via email to