[
https://issues.apache.org/jira/browse/OAK-12422?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Julian Sedding updated OAK-12422:
---------------------------------
Description:
The segment archive recovery process was originally designed for
{{oak-segment-tar}}, where an archive is a single TAR file.
The current recovery orchestration is roughly:
# scan the damaged archive and collect the recoverable segments
# back up the damaged archive (i.e. write to {{*.bak}} archive)
# create a writer for an archive with the original name
# pass every recovered segment to the writer
# close the writer, thereby writing binary references, segment graph and index
For local TAR persistence, backing up the archive is normally a filesystem
rename and rewriting the segments is necessary because the original TAR file
was moved away.
Remote persistence has a different layout: an archive is a directory-like
prefix and every segment is stored as a separate blob or object. The current
remote flow therefore performs substantial redundant I/O:
# download every recoverable segment while scanning the archive
# copy every blob in the archive to {{*.bak}}
# delete every copied blob from the archive
# re-upload every recovered segment to the original archive, effectively
restoring blobs that were just deleted
# write the graph, binary references, index (where applicable), and the closed
marker
Azure SDK v12 batches some copy operations, but the complete archive
copy+delete and the segment re-uploads remain unnecessary. Archives commonly
contain thousands of segments, making this recovery expensive.
The optimized remote flow should be:
# identify which segments should be retained and which segments should be
discarded
# copy only discarded segments to {{*.bak}} and delete them from the original
archive
# leave recoverable segment payloads in their original locations
# parse the retained segments using the existing recovery logic to rebuild the
graph and binary references
# register existing segments with a recovery-aware archive writer instead of
uploading their payloads again
# repair Azure segment metadata if necessary
# rebuild the archive index where applicable
# close the writer to publish the rebuilt metadata and final closed marker
If an expected segment object is not present, recovery must fall back to the
normal segment-write path rather than assuming it can be reused.
was:
The segment archive recovery process was originally designed for
{{oak-segment-tar}}, where it performed the following steps:
# move archive to {{*.bak}}
# open new writer for an archive with the original name
# read each segment from {{*.bak}}
# write each segment via the write
# close the write to write the segment graph, binary-references file and index
However, the same steps don't work so well for remote segment stores, where
each segment is a separate blob (file), unlike the tar-file based
implementation, where each archive is a file. For remote segment stores, the
same steps look as follows:
# copy each segment blob from the original archive to {{*.bak}}
# delete each segment blob from the original archive
# open new writer for an archive with the original name
# read each segment from {{*.bak}}
# write each segment via the write (restores the previously deleted segment!)
# close the write to write the segment graph, binary-references file and index
Steps 1 + 2 are very slow, because they typically copy and then delete 7-10k
segment blobs, which requires 2x number-of-segments requests. These requests
are not currently parallelized. Then, each segment blob is downloaded and
re-uploaded for 4 + 5.
An optimized flow could avoid a lot of redundant I/O:
# copy only redundant segments to {{*.bak}} (ideally none)
# delete only copied segments
# open new writer for the existing archive with the original name
# iterate over the existing segments to populate the metadata structures
(graph, brf, idx)
# update segment metadata if needed
# close the write to write the segment graph, binary-references file and index
> Optimize archive recovery for oak-segment-remote
> ------------------------------------------------
>
> Key: OAK-12422
> URL: https://issues.apache.org/jira/browse/OAK-12422
> Project: Jackrabbit Oak
> Issue Type: Improvement
> Components: segment-aws, segment-azure, segment-remote, segment-tar
> Affects Versions: 2.6.0
> Reporter: Julian Sedding
> Assignee: Julian Sedding
> Priority: Major
>
> The segment archive recovery process was originally designed for
> {{oak-segment-tar}}, where an archive is a single TAR file.
> The current recovery orchestration is roughly:
> # scan the damaged archive and collect the recoverable segments
> # back up the damaged archive (i.e. write to {{*.bak}} archive)
> # create a writer for an archive with the original name
> # pass every recovered segment to the writer
> # close the writer, thereby writing binary references, segment graph and index
> For local TAR persistence, backing up the archive is normally a filesystem
> rename and rewriting the segments is necessary because the original TAR file
> was moved away.
> Remote persistence has a different layout: an archive is a directory-like
> prefix and every segment is stored as a separate blob or object. The current
> remote flow therefore performs substantial redundant I/O:
> # download every recoverable segment while scanning the archive
> # copy every blob in the archive to {{*.bak}}
> # delete every copied blob from the archive
> # re-upload every recovered segment to the original archive, effectively
> restoring blobs that were just deleted
> # write the graph, binary references, index (where applicable), and the
> closed marker
> Azure SDK v12 batches some copy operations, but the complete archive
> copy+delete and the segment re-uploads remain unnecessary. Archives commonly
> contain thousands of segments, making this recovery expensive.
> The optimized remote flow should be:
> # identify which segments should be retained and which segments should be
> discarded
> # copy only discarded segments to {{*.bak}} and delete them from the original
> archive
> # leave recoverable segment payloads in their original locations
> # parse the retained segments using the existing recovery logic to rebuild
> the graph and binary references
> # register existing segments with a recovery-aware archive writer instead of
> uploading their payloads again
> # repair Azure segment metadata if necessary
> # rebuild the archive index where applicable
> # close the writer to publish the rebuilt metadata and final closed marker
> If an expected segment object is not present, recovery must fall back to the
> normal segment-write path rather than assuming it can be reused.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)