Julian Sedding created OAK-12422:
------------------------------------

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


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




--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to