You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "Jose Armando Garcia Sancio (Jira)" <ji...@apache.org> on 2021/03/30 01:12:00 UTC
[jira] [Created] (KAFKA-12576) Renaming log segment should not
result in a copy
Jose Armando Garcia Sancio created KAFKA-12576:
--------------------------------------------------
Summary: Renaming log segment should not result in a copy
Key: KAFKA-12576
URL: https://issues.apache.org/jira/browse/KAFKA-12576
Project: Kafka
Issue Type: Bug
Components: log, log cleaner
Reporter: Jose Armando Garcia Sancio
Assignee: Jose Armando Garcia Sancio
{{FileRecords::renameTo}} uses {{Utils::atomicMoveWithFallback}} to rename the backing File. The implementation for {{Utils::atomicMoveWithFallback}} will perform a non-atomic move if the atomic move fails. This can result in the content of the file being copied.
{{Log}} uses {{FileRecords::renameTo}} indirectly through {{LogSegment::changeFileSuffixes}} while holding the {{Log}} lock to delete segment and to replace clean segments.
This can cause the Kafka process to perform an expensive copy operation while holding a highly contended lock.
Given how {{Utils::atomicMoveWithFallback}} works there is also an issue where {{File file}} and {{FileChannel channel}} point to different file. Meaning writes to {{channel}} are not reflected in the file represented by {{file}}.
{{FileRecors::renameTo}} should be change to use only an atomic move and to fail if it cannot.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)