Adar Dembo has submitted this change and it was merged. ( http://gerrit.cloudera.org:8080/14931 )
Change subject: log: use RWFile in log segments ...................................................................... log: use RWFile in log segments I'm working towards the eventual goal of caching log segments in the file cache, but for that to work, the segments' use of file handles must be safe for caching. Currently they're not: 1. WritableLogSegment uses WritableFile, which has mutable in-memory state. 2. The "active" segment in the log has both a writable and readable log segment open at the same time, each of which uses a different file handle implementation. The file cache could allow that, but it's complexity that I'd rather avoid. 3. The log expects the "active" segment to be truncated and sync'ed when closed, but that's not safe in a world where the segment may drop out of the cache and get closed arbitrarily. We can fix all of these issues by converting log segments to use RWFile. It's not "pure" (especially for ReadableLogSegment which doesn't write), but it gets the job done. There are some notable semantic changes: 1. The log must explicitly truncate/sync when finishing the active segment. 2. Because both kinds of segments now use the same file handle abstraction, we no longer need to close and reopen the underlying file handle when finishing the active segment; we can just share the existing file handle. 3. Likewise, when opening a ReadableLogSegment for the just-switched-to active segment, we can reuse the file handle from the WritableLogSegment rather than opening a second file handle. Change-Id: I65b39e219e76876df16e698211eb558ab31329c8 Reviewed-on: http://gerrit.cloudera.org:8080/14931 Reviewed-by: Andrew Wong <[email protected]> Tested-by: Kudu Jenkins --- M src/kudu/consensus/log-test.cc M src/kudu/consensus/log.cc M src/kudu/consensus/log.h M src/kudu/consensus/log_util.cc M src/kudu/consensus/log_util.h M src/kudu/tserver/tablet_copy_service-test.cc M src/kudu/tserver/tablet_copy_source_session.cc M src/kudu/tserver/tablet_copy_source_session.h 8 files changed, 147 insertions(+), 151 deletions(-) Approvals: Andrew Wong: Looks good to me, approved Kudu Jenkins: Verified -- To view, visit http://gerrit.cloudera.org:8080/14931 To unsubscribe, visit http://gerrit.cloudera.org:8080/settings Gerrit-Project: kudu Gerrit-Branch: master Gerrit-MessageType: merged Gerrit-Change-Id: I65b39e219e76876df16e698211eb558ab31329c8 Gerrit-Change-Number: 14931 Gerrit-PatchSet: 4 Gerrit-Owner: Adar Dembo <[email protected]> Gerrit-Reviewer: Adar Dembo <[email protected]> Gerrit-Reviewer: Andrew Wong <[email protected]> Gerrit-Reviewer: Kudu Jenkins (120)
