Add document describes how a get/commit is done in FDB
This commit is contained in:
parent
85d3e2fee5
commit
7080ea1f1f
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 67 KiB |
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 38 KiB |
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 29 KiB |
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 29 KiB |
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 30 KiB |
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 39 KiB |
|
@ -0,0 +1,204 @@
|
|||
# How a commit is done in FDB
|
||||
|
||||
## Overall description
|
||||
|
||||
Legend:
|
||||
|
||||
* `alt` means alternative paths
|
||||
* The texts in `[]` are conditions
|
||||
* The texts above the arrow are messages.
|
||||
|
||||
The diagrams are generated using https://sequencediagram.org. The source code of the diagrams are the `*.sequence` files.
|
||||
|
||||
![CommitOverall](CommitOverall.svg)
|
||||
|
||||
|
||||
|
||||
## Description of each sections
|
||||
|
||||
Before all RPCs mentioned below, the client would first verify if the commit proxies and GRV proxies are changed, by comparing the client information ID it holds to the ID the cluster coordinator holds. If they are different, the proxies are changed and the client will refresh the proxies list.
|
||||
|
||||
### GetReadVersion Section
|
||||
|
||||
* The GRV Proxy sends a request to master to retrieve the current commit version. This version is the read version of the request.
|
||||
|
||||
### Preresolution Section
|
||||
|
||||
* The commit proxy sends a request for commit version, with a request number.
|
||||
|
||||
* - The request number is a monotonically increasing number per commit proxy.
|
||||
- This ensures for each proxy, the master will process the requests in order.
|
||||
|
||||
* The master server waits until the request number is current.
|
||||
|
||||
When the current request number is larger than the incoming request number
|
||||
|
||||
* If a commit version is already assigned to the incoming request number, return the commit version and the version that is immediately before the commit version (prevVersion).
|
||||
|
||||
* Otherwise return `Never`
|
||||
|
||||
* Increase current commit version, return it back to the commit proxy.
|
||||
|
||||
* Only one process serves as master. Thus the commit version is unique for each cluster.
|
||||
|
||||
* The monotonically increasing commit version will ensure each transaction processed in strict ordering.
|
||||
|
||||
### Resolution section
|
||||
|
||||
* The commit proxy sends the transaction to the resolver.
|
||||
* Resolver waits until its version reaches `prevVersion`
|
||||
* Ensures all transactions having version smaller than this transaction are resolved.
|
||||
* Detects conflicts for the given transaction:
|
||||
* If there is no conflict, return `TransactionCommitted` as the status
|
||||
* Any conflict, return `TransactionConflict` status
|
||||
* If the read snapshot is not in MVCC, return `TransactionTooOld` status
|
||||
|
||||
### Post Resolution section
|
||||
|
||||
* The proxy waits until the local batch number is current
|
||||
* The proxy will update the metadata keys and calculate which storage servers are affected
|
||||
* The proxy then waits until the commit version is current, i.e. only those commits in the MVCC window should be processed.
|
||||
* The proxy pushs the commit data to TLog
|
||||
* TLog waits the commit version to current, then persist the commit.
|
||||
|
||||
### TLog section
|
||||
|
||||
* Wait until *all* TLogs returns the transaction result.
|
||||
|
||||
### Reply section
|
||||
|
||||
* The proxy will update the master its commit version
|
||||
* Reply the result to the client, base on the result from the resolver.
|
||||
|
||||
## Tracking the process using `g_traceBatch`
|
||||
|
||||
`g_traceBatch` can be used for querying the transactions and commits. A typical query string:
|
||||
|
||||
```
|
||||
index=iffdb LogGroup=loggroup Type=location Location=location
|
||||
```
|
||||
|
||||
The format of `location` is, in general, `<source_file_name>.<function/actor name>.<log information>`, e.g.
|
||||
|
||||
```
|
||||
NativeAPI.getConsistentReadVersion.Before
|
||||
```
|
||||
|
||||
means the `location` is at `NativeAPI.actor.cpp`, `ACTOR` `getConsistentReadVersion`, `Before` requesting the read version from GRV Proxy.
|
||||
|
||||
In the following sections, <span style="color:green">green</span> tag indicates an attach; <span style="color:blue">blue</span> tag indicates an event that the location follows the format mentioned above, where only the `<log information>` is included; <span style="color:lightblue">light-blue</span> tag indicates an event that the location is not following the format, where the full location is included. All the `g_traceBatch` events are tabularized after the diagram.
|
||||
|
||||
`contrib/commit_debug.py` can be used to visualize the commit process.
|
||||
|
||||
### Get Read Version
|
||||
|
||||
![GetReadVersion](GRV.svg)
|
||||
|
||||
| **Role** | **File name** | **Function/Actor** | **Trace** | **Type** | **Location** |
|
||||
| ------------ | -------------- | --------------------------- | --------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
|
||||
| **Client** | NativeAPI | Transaction::getReadVersion | | | |
|
||||
| | | readVersionBatcher | | [*TransactionAttachID*](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbclient/NativeAPI.actor.cpp#L4639) | |
|
||||
| | | getConsistentReadVersion | Before | TransactionDebug | [NativeAPI.getConsistentReadVersion.Before](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbclient/NativeAPI.actor.cpp#L4564) |
|
||||
| **GRVProxy** | GrvProxyServer | queueGetReadVersionRequests | Before | TransactionDebug | [GrvProxyServer.queueTransactionStartRequests.Before](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbserver/GrvProxyServer.actor.cpp#L373-L375) |
|
||||
| | | transactionStarter | | [*TransactionAttachID*](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbserver/GrvProxyServer.actor.cpp#L734-L735) | |
|
||||
| | | | AskLiveCommittedVersionFromMaster | TransactionDebug | [GrvProxyServer.transactionStarter.AskLiveCommittedVersionFromMaster](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbserver/GrvProxyServer.actor.cpp#L787-L789) |
|
||||
| | | getLiveCommittedVersion | confirmEpochLive | TransactionDebug | [GrvProxyServer.getLiveCommittedVersion.confirmEpochLive](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbserver/GrvProxyServer.actor.cpp#L479-L480) |
|
||||
| **Master** | MasterServer | serveLiveCommittedVersion | GetRawCommittedVersion | TransactionDebug | [MasterServer.serveLiveCommittedVersion.GetRawCommittedVersion](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbserver/masterserver.actor.cpp#L1187-L1189) |
|
||||
| **GRVProxy** | GrvProxyServer | getLiveCommittedVersion | After | TransactionDebug | [GrvProxyServer.getLiveCommittedVersion.After](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbserver/GrvProxyServer.actor.cpp#L500-L501) |
|
||||
| **Client** | NativeAPI | getConsistentReadVersion | After | TransactionDebug | [NativeAPI.getConsistentReadVersion.After](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbclient/NativeAPI.actor.cpp#L4594-L4595) |
|
||||
|
||||
### Get
|
||||
|
||||
![Get](Get.svg)
|
||||
|
||||
| **Role** | **File name** | **Function/Actor** | **Trace** | **Name** | **Location** | **Notes** |
|
||||
| ------------------ | ------------------- | ----------------------------------- | ------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
|
||||
| **Client** | NativeAPI | Transaction::get | | | | |
|
||||
| | | Transaction::getReadVersion | | | *(Refer to GetReadVersion)* | |
|
||||
| | | getKeyLocation | Before | TransactionDebug | [NativeAPI.getKeyLocation.Before](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbclient/NativeAPI.actor.cpp#L1975-L1976) | getKeyLocation is called by getValue, getKeyLocation actually calls getKeyLocation_internal |
|
||||
| | | | After | TransactionDebug | [NativeAPI.getKeyLocation.After](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbclient/NativeAPI.actor.cpp#L1988-L1989) | |
|
||||
| | | getValue | | [*GetValueAttachID*](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbclient/NativeAPI.actor.cpp#L2164) | | |
|
||||
| | | | Before | GetValueDebug | [NativeAPI.getValue.Before](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbclient/NativeAPI.actor.cpp#L2165-L2167) | |
|
||||
| **Storage Server** | StorageServer | serveGetValueRequests | received | GetValueDebug | [StorageServer.received](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbserver/storageserver.actor.cpp#L4325-L4327) | |
|
||||
| | | getValueQ | DoRead | GetValueDebug | [getValueQ.DoRead](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbserver/storageserver.actor.cpp#L1115-L1117) | |
|
||||
| | | | AfterVersion | GetValueDebug | [getValueQ.AfterVersion](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbserver/storageserver.actor.cpp#L1122-L1124) | |
|
||||
| | KeyValueStoreSQLite | KeyValueStoreSQLite::Reader::action | Before | GetValueDebug | [Reader.Before](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbserver/KeyValueStoreSQLite.actor.cpp#L1654-L1656) | |
|
||||
| | | | After | GetValueDebug | [Reader.After](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbserver/KeyValueStoreSQLite.actor.cpp#L1662-L1664) | |
|
||||
| | StorageServer | | AfterRead | GetValueDebug | [getValueQ.AfterRead](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbserver/storageserver.actor.cpp#L1185-L1187) | |
|
||||
| **Client** | NativeAPI | getValue | After | GetValueDebug | [NativeAPI.getValue.After](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbclient/NativeAPI.actor.cpp#L2216-L2218) | (When successful) |
|
||||
| | | | Error | GetValueDebug | [NativeAPI.getValue.Error](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbclient/NativeAPI.actor.cpp#L2232-L2234) | (Wehn failure) |
|
||||
|
||||
|
||||
|
||||
### Get Range
|
||||
|
||||
![GetRange](GetRange.svg)
|
||||
|
||||
| **Role** | **File name** | **Function/Actor** | **Trace** | **Name** | **Location** | **Notes** |
|
||||
| ------------------ | ------------- | --------------------------- | -------------- | ---------------- | ------------------------------------------------------------ | ------------------------------------ |
|
||||
| **Client** | NativeAPI | Transaction::getRange | | | | |
|
||||
| | | Transaction::getReadVersion | | | *(Refer to GetReadVersion)* | |
|
||||
| | | getKeyLocation | Before | TransactionDebug | [NativeAPI.getKeyLocation.Before](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbclient/NativeAPI.actor.cpp#L1975) | getKeyLocation is called by getRange |
|
||||
| | | | After | TransactionDebug | [NativeAPI.getKeyLocation.After](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbclient/NativeAPI.actor.cpp#L1988-L1989) | |
|
||||
| | | getRange | Before | TransactionDebug | [NativeAPI.getRange.Before](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbclient/NativeAPI.actor.cpp#L3004) | |
|
||||
| **Storage Server** | storageserver | getKeyValuesQ | Before | TransactionDebug | [storageserver.getKeyValues.Before](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbserver/storageserver.actor.cpp#L1812) | |
|
||||
| | | | AfterVersion | TransactionDebug | [storageserver.getKeyValues.AfterVersion](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbserver/storageserver.actor.cpp#L1821) | |
|
||||
| | | | AfterKeys | TransactionDebug | [storageserver.getKeyValues.AfterKeys](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbserver/storageserver.actor.cpp#L1846) | |
|
||||
| | | | Send | TransactionDebug | [storageserver.getKeyValues.Send](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbserver/storageserver.actor.cpp#L1866) | (When no keys found) |
|
||||
| | | | AfterReadRange | TransactionDebug | [storageserver.getKeyValues.AfterReadRange](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbserver/storageserver.actor.cpp#L1886) | (When found keys in this SS) |
|
||||
| **Client** | NativeAPI | getRange | After | TransactionDebug | [NativeAPI.getRange.After](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbclient/NativeAPI.actor.cpp#L3044-L3046) | (When successful) |
|
||||
| | | | Error | TransactionDebug | [NativeAPI.getRange.Error](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbclient/NativeAPI.actor.cpp#L3155-L3156) | (Wehn failure) |
|
||||
|
||||
### GetRange Fallback
|
||||
|
||||
![GetRangeFallback](GetRangeFallback.svg)
|
||||
|
||||
| **Role** | **File name** | **Function/Actor** | **Trace** | **Type** | **Location** | **Notes** |
|
||||
| ---------- | ------------- | -------------------- | ------------ | ---------------- | ------------------------------------------------------------ | ----------------------------------------------- |
|
||||
| **Client** | NativeAPI | getRangeFallback | | | | |
|
||||
| | | getKey | | | *GetKeyAttachID* | |
|
||||
| | | | AfterVersion | GetKeyDebug | [NativeAPI.getKey.AfterVersion](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbclient/NativeAPI.actor.cpp#L2263-L2266) | |
|
||||
| | | | Before | GetKeyDebug | [NativeAPI.getKey.Before](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbclient/NativeAPI.actor.cpp#L2285-L2288) | |
|
||||
| | | | After | GetKeyDebug | [NativeAPI.getKey.After](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbclient/NativeAPI.actor.cpp#L2316-L2318) | Success |
|
||||
| | | | Error | GetKeyDebug | [NativeAPI.getKey.Error](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbclient/NativeAPI.actor.cpp#L2326) | Error |
|
||||
| | | getReadVersion | | | | *(Refer to GetReadVersion)* |
|
||||
| | | getKeyRangeLocations | Before | TransactionDebug | [NativeAPI.getKeyLocations.Before](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbclient/NativeAPI.actor.cpp#L2029) | |
|
||||
| | | | After | TransactionDebug | [NativeAPI.getKeyLocations.After](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbclient/NativeAPI.actor.cpp#L2044) | |
|
||||
| | | getExactRange | Before | TransactionDebug | [NativeAPI.getExactRange.Before](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbclient/NativeAPI.actor.cpp#L2674) | getKeyRangeLocations is called by getExactRange |
|
||||
| | | | After | TransactionDebug | [NativeAPI.getExactRange.After](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbclient/NativeAPI.actor.cpp#L2707) | |
|
||||
|
||||
### Commit
|
||||
|
||||
![Commit](Commit.svg)
|
||||
|
||||
| **Role** | **File name** | **Function/Actor** | **Trace** | **Type** | **Location** | **Notes** |
|
||||
| ---------------- | ----------------- | ------------------------------------------- | -------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | --------- |
|
||||
| **Client** | NativeAPI | Transaction::commit | | | | |
|
||||
| | | commitAndWatch | | | | |
|
||||
| | | tryCommit | | *[commitAttachID](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbclient/NativeAPI.actor.cpp#L4100)* | | |
|
||||
| | | | Before | CommitDebug | [NativeAPI.commit.Before](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbclient/NativeAPI.actor.cpp#L4101-L4102) | |
|
||||
| **Commit Proxy** | CommitProxyServer | commitBatcher | batcher | CommitDebug | [CommitProxyServer.batcher](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbserver/CommitProxyServer.actor.cpp#L244-L245) | |
|
||||
| | | commitBatch | | | | |
|
||||
| | | CommitBatchContext::setupTraceBatch | | *[CommitAttachID](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbserver/CommitProxyServer.actor.cpp#L526)* | | |
|
||||
| | | | Before | CommitDebug | [CommitProxyServer.commitBatch.Before](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbserver/CommitProxyServer.actor.cpp#L532) | |
|
||||
| | | CommitBatchContext::preresolutionProcessing | GettingCommitVersion | CommitDebug | [CommitProxyServer.commitBatch.GettingCommitVersion](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbserver/CommitProxyServer.actor.cpp#L616-L617) | |
|
||||
| | | | GotCommitVersion | CommitDebug | [CommitProxyServer.commitBatch.GotCommitVersion](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbserver/CommitProxyServer.actor.cpp#L643) | |
|
||||
| **Resolver** | Resolver | resolveBatch | | *[CommitAttachID](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbserver/Resolver.actor.cpp#L116)* | | |
|
||||
| | | | Before | CommitDebug | [Resolver.resolveBatch.Before](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbserver/Resolver.actor.cpp#L117) | |
|
||||
| | | | AfterQueueSizeCheck | CommitDebug | [Resolver.resolveBatch.AfterQueueSizeCheck](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbserver/Resolver.actor.cpp#L137) | |
|
||||
| | | | AfterOrderer | CommitDebug | [Resolver.resolveBatch.AfterOrderer](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbserver/Resolver.actor.cpp#L172) | |
|
||||
| | | | After | CommitDebug | [Resolver.resolveBatch.After](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbserver/Resolver.actor.cpp#L296) | |
|
||||
| **Commit Proxy** | CommitProxyServer | CommitBatchContext::postResolution | ProcessingMutations | CommitDebug | [CommitProxyServer.CommitBatch.ProcessingMutations](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbserver/CommitProxyServer.actor.cpp#L1074) | |
|
||||
| | | | AfterStoreCommits | CommitDebug | [CommitProxyServer.CommitBatch.AfterStoreCommits](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbserver/CommitProxyServer.actor.cpp#L1154) | |
|
||||
| **TLog** | TLogServer | tLogCommit | | *[commitAttachID](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbserver/TLogServer.actor.cpp#L2047)* | | |
|
||||
| | | | BeforeWaitForVersion | CommitDebug | [TLogServer.tLogCommit.BeforeWaitForVersion](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbserver/TLogServer.actor.cpp#L2048) | |
|
||||
| | | | Before | CommitDebug | [TLog.tLogCommit.Before](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbserver/TLogServer.actor.cpp#L2083) | |
|
||||
| | | | AfterTLogCommit | CommitDebug | [TLog.tLogCommit.AfterTLogCommit](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbserver/TLogServer.actor.cpp#L2107) | |
|
||||
| | | | After | CommitDebug | [TLog.tLogCommit.After](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbserver/TLogServer.actor.cpp#L2125) | |
|
||||
| **Commit Proxy** | CommitProxyServer | CommitBatchContext::reply | AfterLogPush | CommitDebug | [CommitProxyServer.CommitBatch.AfterLogPush](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbserver/CommitProxyServer.actor.cpp#L1263) | |
|
||||
| **Client** | NativeAPI | tryCommit | After | CommitDebug | [NativeAPI.commit.After](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbclient/NativeAPI.actor.cpp#L4152) | |
|
||||
| | | commitAndWatch | | | | |
|
||||
| | | watchValue | | *[WatchValueAttachID](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbclient/NativeAPI.actor.cpp#L2408)* | | |
|
||||
| | | | Before | WatchValueDebug | [NativeAPI.watchValue.Before]() | |
|
||||
| | | | After | WatchValueDebug | [NativeAPI.watchValue.After](https://github.com/apple/foundationdb/blob/ffb8e27f4325db3dc8465e145bc308f6854500eb/fdbclient/NativeAPI.actor.cpp#L2431-L2433) | |
|
||||
|
|
@ -0,0 +1,148 @@
|
|||
title Commit
|
||||
|
||||
participantgroup **Client** (NativeAPI.actor.cpp)
|
||||
participant "Transaction::commit" as tC
|
||||
participant "commitAndWatch" as cAW
|
||||
participant "tryCommit" as Commit
|
||||
participant "watchValue" as wV
|
||||
end
|
||||
|
||||
participantgroup **CommitProxy** (CommitProxyServer.actor.cpp)
|
||||
participant "commitBatcher" as cB
|
||||
participant "commitBatch" as Batch
|
||||
participant "TagPartitionedLogSystem" as TPLS
|
||||
end
|
||||
|
||||
participantgroup **Master**
|
||||
participant "getVersion" as gV
|
||||
participant "serveLiveCommittedVersion" as sLCV
|
||||
end
|
||||
|
||||
participantgroup **Resolver** (Resolver.actor.cpp)
|
||||
participant "resolveBatch" as rB
|
||||
end
|
||||
|
||||
participantgroup **TLog** (TLogServer.actor.cpp)
|
||||
participant "tLogCommit" as tLC
|
||||
end
|
||||
|
||||
participantgroup **Storage Server** (storageserver.actor.cpp)
|
||||
participant "serveWatchValueRequests" as sWVR
|
||||
end
|
||||
|
||||
autoactivation off
|
||||
|
||||
tC -> cAW:
|
||||
cAW -> Commit: CommitTransactionRequest
|
||||
|
||||
note right of Commit: <color:#green>//CommitAttachID//</color>
|
||||
note right of Commit: <color:#lightblue>NativeAPI.commit.Before</color>
|
||||
|
||||
Commit -> cB: CommitTransactionRequest
|
||||
loop Batch requests
|
||||
box over cB: Batch commit requests
|
||||
end
|
||||
|
||||
cB -> Batch: Batched CommitTransactionRequests
|
||||
|
||||
note right of Batch: <color:#lightblue>--CommitProxyServer.batcher--</color>
|
||||
|
||||
box over Batch: Preresolution
|
||||
|
||||
note right of Batch: <color:#blue>GettingCommitVersion</color>
|
||||
|
||||
Batch -> gV: GetCommitVersionRequest
|
||||
gV -> Batch: GetCommitVersionReply
|
||||
|
||||
note right of Batch: <color:#blue>GotCommitVersion</color>
|
||||
|
||||
box over Batch: Resolve
|
||||
|
||||
Batch -> rB: ResolveTransactionBatchRequest
|
||||
|
||||
note right of rB: <color:#blue>Before</color>
|
||||
|
||||
box over rB: Wait for memory/needed version
|
||||
|
||||
note right of rB: <color:#blue>AfterQueueSizeCheck</color>
|
||||
|
||||
box over rB: Wait for resolver version
|
||||
|
||||
note right of rB: <color:#blue>AfterOrderer</color>
|
||||
|
||||
box over rB: Resolve the conflicts
|
||||
|
||||
note right of rB: <color:#blue>After</color>
|
||||
|
||||
rB --> Batch: ResolveTransactionBatchReply
|
||||
|
||||
note right of Batch: <color:#blue>ProcessingMutations</color>
|
||||
|
||||
box over Batch: Calculate the metadata
|
||||
|
||||
box over Batch: Determine which transactions should be committed
|
||||
|
||||
box over Batch: Assign storage server tags to mutations
|
||||
|
||||
loop Wait txn commit version enter the MVCC window
|
||||
Batch -> sLCV: GetRawCommittedVersionRequest
|
||||
sLCV --> Batch: GetRawCommittedVersionReply
|
||||
end
|
||||
|
||||
note right of Batch: <color:#blue>AfterStoreCommits</color>
|
||||
|
||||
Batch -> TPLS: Version, LogPushData
|
||||
TPLS -> tLC: TLogCommitRequest
|
||||
|
||||
note right of tLC: <color:#green>//CommitAttachID//</color>
|
||||
|
||||
note right of tLC: <color:#blue>BeforeWaitForVersion</color>
|
||||
|
||||
box over tLC: Wait for the version
|
||||
|
||||
note right of tLC: <color:#blue>Before</color>
|
||||
|
||||
box over tLC: Store the commit
|
||||
|
||||
box over tLC: Put commit into persistent queue
|
||||
|
||||
note right of tLC: <color:#blue>AfterTLogCommit</color>
|
||||
|
||||
box over tLC: Wait all prior message being committed
|
||||
|
||||
note right of tLC: <color:#blue>After</color>
|
||||
|
||||
tLC --> TPLS: TLogCommitReply
|
||||
TPLS -> Batch: Version (min)
|
||||
|
||||
note right of Batch: AfterLogPush
|
||||
|
||||
Batch --> Commit: CommitID
|
||||
|
||||
note right of Commit: <color:#lightblue>--NativeAPI.commit.After--</color>
|
||||
|
||||
Commit --> cAW:
|
||||
|
||||
cAW -> wV: Version
|
||||
|
||||
note right of wV: <color:#green>//WatchValueAttachID//</color>
|
||||
note right of wV: <color:#blue>Before</color>
|
||||
|
||||
wV -> sWVR: WatchValueRequest
|
||||
|
||||
note right of sWVR: <color:#lightblue>--watchValueQ.Before--</color>
|
||||
|
||||
box over sWVR: Ensure version is not too old
|
||||
|
||||
note right of sWVR: <color:#lightblue>--watchValueQ.AfterVersion--</color>
|
||||
|
||||
loop Value not change
|
||||
box over sWVR: Check storageserver::getValueQ
|
||||
note right of sWVR: <color:#lightblue>--watchValueQ.AfterRead--</color>
|
||||
end
|
||||
|
||||
sWVR --> wV: Version
|
||||
|
||||
note right of wV: <color:#blue>After</color>
|
||||
|
||||
cAW --> tC:
|
|
@ -0,0 +1,54 @@
|
|||
title Commit in FoundationDB
|
||||
|
||||
participant "Client" as C
|
||||
participant "GetReadVersionProxy" as GRV
|
||||
participant "CommitProxy" as P
|
||||
participant "Master" as M
|
||||
participant "Resolver" as R
|
||||
participant "TLog" as T
|
||||
|
||||
C ->> GRV: Request read version
|
||||
GRV ->> M: Request committed version
|
||||
M ->> GRV: Respond committed version
|
||||
GRV ->> C: Respond read version
|
||||
|
||||
C ->> P: Commit a mutation with read version
|
||||
|
||||
box right of P: Pre-resolution
|
||||
P ->> M: Request a commit version
|
||||
alt New request
|
||||
M ->> P: Commit version
|
||||
else Replied before with a commit version
|
||||
M ->> P: Commit version
|
||||
else Replied before without commit version
|
||||
M --x P: Never
|
||||
end
|
||||
|
||||
box right of P: Resolution
|
||||
P ->> R: Send the transaction to the resolver
|
||||
alt No conflict
|
||||
R ->> P: TransactionCommitted
|
||||
else Conflict
|
||||
R ->> P: TransactionConflict
|
||||
else Read snapshot older than oldest version
|
||||
R ->> P: TransactionTooOld
|
||||
end
|
||||
|
||||
box right of P: Post-resolution
|
||||
P ->> T: Push the transaction data to TLog
|
||||
alt TLog not stopped
|
||||
T ->> P: The version of the transactions that are already durable
|
||||
else TLog stopped
|
||||
T ->> P: tlog_stopped
|
||||
end
|
||||
|
||||
box right of P: Reply
|
||||
P ->> M: Report raw commit version
|
||||
M -->> P: Void
|
||||
alt Commit successful
|
||||
P ->> C: Commit version
|
||||
else Conflict
|
||||
P ->> C: Not committed: conflict
|
||||
else Transaction too old
|
||||
P ->> C: Not committed: too old
|
||||
end
|
|
@ -0,0 +1,68 @@
|
|||
title Get
|
||||
|
||||
participantgroup **Client** (NativeAPI.actor.cpp)
|
||||
participant "Transaction::get" as get
|
||||
participant "Transaction::getReadVersion" as gRV
|
||||
participant "getValue" as gV
|
||||
participant "getKeyLocation" as gKL
|
||||
end
|
||||
|
||||
participantgroup **CommitProxy** (CommitProxyServer.actor.cpp)
|
||||
participant "doKeyServerLocationRequest" as dKSLR
|
||||
end
|
||||
|
||||
participantgroup **Storage Server** (storageserver.actor.cpp)
|
||||
participant "serveGetValueRequests" as sGVR
|
||||
participant "getValueQ" as gVQ
|
||||
end
|
||||
|
||||
participantgroup **KeyValueStoreSQLite** (KeyValueStoreSQLite.actor.cpp)
|
||||
participant "KeyValueStoreSQLite::Reader::action" as axn
|
||||
end
|
||||
|
||||
autoactivation off
|
||||
|
||||
get -> gRV:
|
||||
box over gRV: //Consult Get Read Version section//
|
||||
gRV --> get: Version
|
||||
|
||||
get -> gV: Version, Key
|
||||
gV -> gKL: Key
|
||||
note right of gKL: <color:#blue>Before</color>
|
||||
|
||||
gKL -> dKSLR: GetKeyServerLocationsRequest
|
||||
dKSLR --> gKL: GetKeyServerLocationsReply
|
||||
|
||||
note right of gKL: <color:#blue>After</color>
|
||||
|
||||
gKL --> gV: LocationInfo
|
||||
|
||||
note right of gV: <color:#green>//GetValueAttachID//</color>
|
||||
|
||||
note right of gV: <color:#blue>Before</color>
|
||||
|
||||
gV -> sGVR: GetValueRequest
|
||||
note right of sGVR: <color:#lightblue>--storageServer.received--</color>
|
||||
|
||||
sGVR -> gVQ: GetValueRequest
|
||||
|
||||
note right of gVQ: <color:#lightblue>--getValueQ.DoRead--</color>
|
||||
|
||||
note right of gVQ: <color:#lightblue>--getValueQ.AfterVersion--</color>
|
||||
|
||||
gVQ -> axn: Key
|
||||
|
||||
note right of axn: <color:#lightblue>--Reader.Before--</color>
|
||||
note right of axn: <color:#lightblue>--Reader.After--</color>
|
||||
|
||||
axn --> gVQ: Value
|
||||
note right of gVQ: <color:#lightblue>--getValueQ.AfterRead--</color>
|
||||
|
||||
gVQ --> gV: GetValueReply
|
||||
alt Error
|
||||
note right of gV: <color:#blue>Error</color>
|
||||
gV --> get: Error
|
||||
else Success
|
||||
note right of gV: <color:#blue>After</color>
|
||||
gV --> get: Value
|
||||
end
|
|
@ -0,0 +1,60 @@
|
|||
title GetRange
|
||||
|
||||
participantgroup **Client** (NativeAPI.actor.cpp)
|
||||
participant "Transaction::getRange" as tGR
|
||||
participant "Transaction::getReadVersion" as gRV
|
||||
participant "getRange" as gR
|
||||
participant "getKeyLocation" as gKL
|
||||
end
|
||||
|
||||
participantgroup **Storage Server** (storageserver.actor.cpp)
|
||||
participant "getKeyValuesQ" as gKVQ
|
||||
end
|
||||
|
||||
autoactivation off
|
||||
|
||||
tGR -> gRV:
|
||||
tGR -> gR: KeyRange
|
||||
gRV -->(2) gR: Version
|
||||
|
||||
loop Keys in the range
|
||||
gR -> gKL: Key
|
||||
|
||||
box over gKL: //Consult Get section//
|
||||
|
||||
gKL --> gR: LocationInfo
|
||||
|
||||
note right of gR: <color:#blue>Before</color>
|
||||
|
||||
gR -> gKVQ: GetKeyValuesRequest
|
||||
|
||||
note right of gKVQ: <color:#lightblue>--storageserver.getKeyValues.Before--</color>
|
||||
|
||||
box over gKVQ: Wait the SS version
|
||||
|
||||
note right of gKVQ: <color:#lightblue>--storageserver.getKeyValues.AfterVersion--</color>
|
||||
|
||||
box over gKVQ: Realign the keys
|
||||
|
||||
note right of gKVQ: <color:#lightblue>--storageserver.getKeyValues.AfterKeys--</color>
|
||||
|
||||
alt No KV pair stored in this server
|
||||
note right of gKVQ: <color:#lightblue>--storageserver.getKeyValues.Send--</color>
|
||||
gKVQ --> gR: GetKeyValuesReply (empty)
|
||||
else KV pair found
|
||||
note right of gKVQ: <color:#lightblue>--storageserver.getKeyValues.AfterReadRange--</color>
|
||||
gKVQ --> gR: GetKeyValuesReply
|
||||
end
|
||||
|
||||
note right of gR: <color:#blue>After</color>
|
||||
|
||||
box over gR: Combines the results
|
||||
end
|
||||
|
||||
alt Error
|
||||
note right of gR: <color:#blue>Error</color>
|
||||
box over gR: Fallback
|
||||
gR -> tGR: RangeResultRef or Error
|
||||
else Successful
|
||||
gR -> tGR: RangeResultRef
|
||||
end
|
|
@ -0,0 +1,80 @@
|
|||
title GetRange Fallback
|
||||
|
||||
participantgroup **Client** (NativeAPI.actor.cpp)
|
||||
participant "getRangeFallback" as gRF
|
||||
participant "getKey" as gK
|
||||
participant "getExactRange" as gER
|
||||
participant "getKeyRangeLocations" as gKRL
|
||||
end
|
||||
|
||||
participantgroup **Storage Server** (storageserver.actor.cpp)
|
||||
participant "serveGetKeyValuesRequests" as sGKVR
|
||||
participant "serveGetKeyRequests" as sGKR
|
||||
end
|
||||
|
||||
autoactivation off
|
||||
|
||||
opt Key need resolve
|
||||
gRF -> gK: KeySelector
|
||||
|
||||
box over gK: Wait for the version
|
||||
|
||||
note right of gK: <color:#green>//GetKeyAttachID//</color>
|
||||
note right of gK: <color:#blue>AfterVersion</color>
|
||||
|
||||
box over gK: See getKeyLocation in Get
|
||||
|
||||
note right of gK: <color:#blue>Before</color>
|
||||
|
||||
gK -> sGKR: GetKeyRequest
|
||||
sGKR --> gK: GetKeyReply
|
||||
|
||||
alt Success
|
||||
note right of gK: <color:#blue>After</color>
|
||||
gK --> gRF: Key
|
||||
else Error
|
||||
note right of gK: <color:#blue>Error</color>
|
||||
end
|
||||
end
|
||||
|
||||
box over gRF: Update read version if necessary
|
||||
|
||||
gRF -> gER: Version, KeyRangeRef
|
||||
|
||||
loop Loop over keys in the range
|
||||
gER -> gKRL: KeyRange
|
||||
|
||||
note right of gKRL: <color:#blue>Before</color>
|
||||
box over gKRL: Get the locations
|
||||
note right of gKRL: <color:#blue>After</color>
|
||||
|
||||
gKRL --> gER: LocationInfo
|
||||
|
||||
loop Loop over shards
|
||||
note right of gER: <color:#blue>Before</color>
|
||||
|
||||
gER -> sGKVR: GetKeyValuesRequest
|
||||
|
||||
note right of sGKVR: <color:#lightblue>--storageserver.getKeyValues.Before--</color>
|
||||
|
||||
box over sGKVR: Wait the SS version
|
||||
|
||||
note right of sGKVR: <color:#lightblue>--storageserver.getKeyValues.AfterVersion--</color>
|
||||
|
||||
box over sGKVR: Realign the keys
|
||||
|
||||
note right of sGKVR: <color:#lightblue>--storageserver.getKeyValues.AfterKeys--</color>
|
||||
|
||||
alt No KV pair stored in this server
|
||||
note right of sGKVR: <color:#lightblue>--storageserver.getKeyValues.Send--</color>
|
||||
sGKVR --> gER: GetKeyValuesReply (empty)
|
||||
else KV pair found
|
||||
note right of sGKVR: <color:#lightblue>--storageserver.getKeyValues.AfterReadRange--</color>
|
||||
sGKVR --> gER: GetKeyValuesReply
|
||||
end
|
||||
|
||||
note right of gER: <color:#blue>After</color>
|
||||
end
|
||||
end
|
||||
|
||||
gER --> gRF: RangeResultRef
|
|
@ -0,0 +1,66 @@
|
|||
title Get Read Version
|
||||
|
||||
participantgroup **Client** (NativeAPI.actor.cpp)
|
||||
participant "Transaction::getReadVersion" as gRV
|
||||
participant "readVersionBatcher" as rVB
|
||||
participant "getConsistentReadVersion" as gCRV
|
||||
end
|
||||
|
||||
participantgroup **GRVProxy** (GrvProxyServer.actor.cpp)
|
||||
participant "queueGetReadVersionRequests" as qGRVR
|
||||
participant "transactionStarter" as tS
|
||||
participant "getLiveCommittedVersion" as gLCV
|
||||
end
|
||||
|
||||
participantgroup **Master** (masterserver.actor.cpp)
|
||||
participant "serveLiveCommittedVersion" as sLCV
|
||||
end
|
||||
|
||||
autoactivation off
|
||||
|
||||
gRV -> rVB: VersionRequest
|
||||
|
||||
loop Batch requests
|
||||
box over rVB:Batch read version requests
|
||||
end
|
||||
|
||||
note right of rVB: <color:#green>//TransactionAttachID//</color>
|
||||
|
||||
rVB -> gCRV:
|
||||
|
||||
note right of gCRV: <color:#blue>Before</color>
|
||||
|
||||
gCRV -> qGRVR: GetReadVersionRequest
|
||||
|
||||
loop Batch requests
|
||||
box over qGRVR: Batch read version requests
|
||||
end
|
||||
|
||||
note right of qGRVR: <color:#lightblue>--GrvProxyServer.queueTransactionStartRequests.Before--</color>
|
||||
|
||||
qGRVR -> tS:
|
||||
|
||||
note right of tS: <color:#green>//TransactionAttachID//</color>
|
||||
|
||||
note right of tS: <color:#blue>AskLiveCommittedVersionFromMaster</color>
|
||||
|
||||
tS -> gLCV:
|
||||
|
||||
note right of gLCV: <color:#blue>confirmEpochLive</color>
|
||||
|
||||
gLCV -> sLCV: GetRawCommittedVersionRequest
|
||||
|
||||
note right of sLCV: <color:#blue>GetRawCommittedVersion</color>
|
||||
|
||||
sLCV --> gLCV: GetRawCommittedVersionReply
|
||||
|
||||
note right of gLCV: <color:#blue>After</color>
|
||||
|
||||
gLCV --> gCRV: GetReadVersionReply
|
||||
|
||||
note right of gCRV: <color:#blue>After</color>
|
||||
|
||||
gCRV --> rVB: GetReadVersionReply
|
||||
|
||||
rVB --> gRV: GetReadVersionReply
|
||||
|
Loading…
Reference in New Issue