Commit Graph

179 Commits

Author SHA1 Message Date
Meng Xu 450bda9a01 FastRestore:Refactor parsing backup file code
Refactor _parseRangeFileToMutationsOnLoader and
_parseLogFileToMutationsOnLoader functions and their callees
2019-05-30 14:01:48 -07:00
Meng Xu a3f61e6df7 FastRestore:Rafctor:Reduce code size
1) Use runRYWTransaction to replace the loop-try style;
2) Remove unnecessary printf
3) Do not mistakenly send reply twice.
2019-05-29 17:03:50 -07:00
Meng Xu 9e1216af1c FastRestore:Remove CMDUID 2019-05-29 13:48:04 -07:00
Meng Xu 4f484a2a5d FastRestore:Refactor out the use of cmdID and other non-must functions 2019-05-29 13:26:17 -07:00
Meng Xu d56837ba16 FastRestore:Refactor LoadFileRequest
1) Remove global map to buffer the parsed mutations on loader.
   Use local map instead to increase parallelism.
2) Use std::map<LoadingParam, Future<Void>> to hold the actor
that parse a backup file and to de-duplicate requests.
3) Remove unused code.
2019-05-28 18:39:00 -07:00
Meng Xu fe2624fc22 FastRestore:Remove sampling phase
Remove the sampling phase to make the PR easier to review.
The sampling design and implementation may be changed and added in
next PR.
2019-05-26 21:34:58 -07:00
Meng Xu 3eadb31798 FastRestore:Resolve two major reveiw comments
1) Add sendBatchRequests and getBatchReplies

sendBatchRequests is a generic actor to send requests without
processing replies.
getBatchReplies is similar to sendBatchRequests expect that
it returns the reply to caller.

2) Share applier interface to loaders by using RequestStream,
instead of using DB.
   Create RestoreSysInfo struct, similar purpose as DBInfo, for
 the restore system information that are shared among restore workers.
2019-05-24 21:53:21 -07:00
Meng Xu fac63a83c4 FastRestore:Use NotifiedVersion to deduplicate requests
Add a NotifiedVersion into an applier data which represents
the smallest version the applier is at.

When a loader sends mutation vector to appliers, it sends
the request that contains prevVersion and commitVersion.

This commits also put actor into an actorCollector for
loop-choose-when situation.
2019-05-22 22:09:54 -07:00
Meng Xu 12817af03f FastRestore:Fix CMake compiling errors 2019-05-16 20:01:43 -07:00
Meng Xu 35b169fd2d FastRestore:Fix bug in registerMutationsToApplier
We forgot to update the applierInterface reference to the iterated
applyID
2019-05-14 22:10:09 -07:00
Meng Xu d9c97b5e5f FastRestore:Fix bug in sending a vector of mutations
When mutationVectorThreshold is not 1, a loader sends a vector of
mutations to an applier.

We should never mix mutations at different versions into the same vector.

The code on previous commit may mix mutations at versions.
This commit resolves the bug.
2019-05-14 21:04:36 -07:00
Meng Xu f33e3bf8bc FastRestore:bugFix:loader must clear kvOps after use it
In the sampling phase, a loader will cache the mutations into kvOps map;
In the loading log file phase, the loader will do the same thing.
The loader must clear the kvOps map once the loader use it; otherwise,
it will cache the sampled mutations twice, which leads to an
inconsistent restored DB.
2019-05-14 20:28:32 -07:00
Meng Xu f54a1e1463 FastRestore:Fix bug in deciding applierID in splitMutation 2019-05-14 17:39:44 -07:00
Meng Xu f8c654cd86 FastRestore:Fix splitMutation bug
The splitted range mutation had a wrong param1 for the produced first mutation
2019-05-14 17:05:50 -07:00
Meng Xu 1f159113e6 FastRestore:Test multiple appliers
Loaders will split a range mutation for multiple appliers when needed.
2019-05-14 16:41:04 -07:00
Meng Xu 6c4c807801 FastRestore:fix bug due to non-unique cmdid
This commit identifies the bug
why DB may be restored to an inconsistent state.

The cmdid is used to achieve exact once delivery even when
network can deliver a request twice.
This is under assumption that cmdid is unique for each request!

However, this assumption may not hold for
the phase Loader_Send_Mutations_To_Applier, when loaders send parsed
mutations to appliers:
1) When the same loader loads multiple files, we reset the cmdid
for the phase;
2) When different loaders load files, each loader's cmdid starts from
0 for the phase.
Both situations can break the assumption, which causes appliers to
miss some mutations to apply. This breaks the cycle test.
2019-05-14 01:49:49 -07:00
Meng Xu c115e3ceb1 FastRestore: Remove handleSampleLogFileRequest
handleSampleLogFileRequest is replaced by handleLoadLogFileRequest
2019-05-13 18:49:13 -07:00
Meng Xu 730142d532 FastRestore: Mark sampled file as processed files
This commit should pass correctness test, but
it does not mean the fast restore logic is correct.

We should NOT mark sampled file as processed files.
2019-05-13 17:53:11 -07:00
Meng Xu 76dd8dc8a8 FastRestore: Fix splitMutation bug 2019-05-13 17:24:57 -07:00
Meng Xu c7cd758e01 FastRestore:Do not mark log file as processed in sampling
This commit will expose a potential bug in fast restore.
We may need to parse range file before log file.
2019-05-13 11:37:20 -07:00
Meng Xu 26b224cddc FastRestore:RestoreLoader: Unify parsing log file
Use a generic actor to parse log files for sampling phase and
load phase.
2019-05-13 11:36:29 -07:00
Meng Xu a2fef23678 FastRestore: Remove handleSampleRangeFile actor 2019-05-13 10:36:44 -07:00
Meng Xu 48e7897c9a FastRestore: RestoreLoader: Unify parsing range file
Handle the request of parsing range files in the same function for
both sampling phase and loading phase.
2019-05-12 23:15:58 -07:00
Meng Xu fd92ab64e4 FastRestore: Clean code for RestoreApplier
Remove unused code and add comments to actors
2019-05-12 22:05:55 -07:00
Meng Xu 620cdd411e FastRestore:Add comments for each restore file 2019-05-12 21:53:43 -07:00
Meng Xu 32c030b7d6 FastRestore: Clear RestoreRole key in DB at finishRestore
This commit is the one that passes correctness tests after
refactoring the fast restore.
2019-05-11 22:25:36 -07:00
Meng Xu 879bf8dc7b FastRestore: Bug fix for refactored code 2019-05-10 16:48:01 -07:00
Meng Xu a08a6776f5 FastRestore: Refactor to smaller components
The current code uses one restore interface to handle the work
for all restore roles, i.e., master, loader and applier.
This makes it harder to review or maintain or scale.

This commit split the restore into multiple roles by mimicing FDB
transaction system:
1) It uses a RestoreWorker as the process to host restore roles;
   This commit assumes one restore role per RestoreWorker; but
   it should be easy to extend to support multiple roles per RestoreWorker;
2) It creates 3 restore roles:
   RestoreMaster: Coordinate the restore process and send commands to the other two roles;
   RestoreLoader: Parse backup files to mutations and send mutations to appliers;
   RestoreApplier: Sort received mutations and apply them to DB in order.

Compilable version. To be tested in correctness.
2019-05-10 14:20:06 -07:00
Meng Xu 25c75f4222 FastRestore: Add new empty files for restore roles
Add .h and .cpp files for RestoreLoader and RestoreApplier roles.
We will split the code for each restore role into a separate file.

This commit also fixes the bug in including RestoreCommon.actor.h, and
remove the unused code.
2019-05-06 16:59:41 -07:00