ccding opened a new pull request #10763:
URL: https://github.com/apache/kafka/pull/10763


   When we find a .swap file on startup, we typically want to rename and 
replace it as .log, .index, .timeindex, etc. as a way to complete any ongoing 
replace operations. These swap files are usually known to have been flushed to 
disk before the replace operation begins.
   
   One flaw in the current logic is that we recover these swap files on startup 
and as part of that, end up truncating the producer state and rebuild it from 
scratch. This is unneeded as the replace operation does not mutate the producer 
state by itself. It is only meant to replace the .log file along with 
corresponding indices. Because of this unneeded producer state rebuild 
operation, we have seen multi-hour startup times for clusters that have large 
compacted topics.
   
   This patch fixes the issue. With ext4 ordered mode, the metadata are ordered 
and no matter it is a clean/unclean shutdown, if at least one `.swap` file 
exists for a segment, all other files for the segment must exist as `.cleaned` 
files or `.swap` files. Therefore, we rename the `.cleaned` files to `.swap` 
files, then make them normal segment files.. If they don't pass the sanity 
check, we fall back to the original path and repair all the index files.
   
   TODO: run validate the patch
   
   ### Committer Checklist (excluded from commit message)
   - [ ] Verify design and implementation 
   - [ ] Verify test coverage and CI build status
   - [ ] Verify documentation (including upgrade notes)
   


-- 
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