-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow overriding LogIdList::load_log_ids
by providing the information directly from the state machine or log reader
#1261
Comments
👋 Thanks for opening this issue! Get help or engage by:
|
Why is such key-log-id metadata stored in state machine? shouldn't be part of the Raft log? Does your state machine provide the complete key-log-id or just the applied log-ids? If there are some logs that are not in state machine, Openraft still needs several other rounds of RaftLogStorage access to locate these key log ids. |
For us, the state machine includes log storage. So the two
All log IDs which were logged, also not applied. Key log IDs are part of log segment management (and stored in log segment metadata). So we can quickly reconstruct the entire set of key log IDs (leader changes) from this metadata w/o loading the log proper. |
So, it could be another RaftLogStorage API to return all of the key log id. |
Yes. Sorry for the confusion. |
Key log IDs represent the first log IDs proposed by each Leader. These IDs enable Openraft to efficiently access log IDs at each index with a succinct storage. Previously, key log IDs were obtained using a binary-search-like algorithm through `RaftLogReader`. This commit introduces the `RaftLogReader::get_key_log_ids()` method, allowing implementations to directly return a list of key log IDs if the `RaftLogStorage` can provide them. For backward compatibility, a default implementation using the original binary-search method is provided. No application changes are required when upgrading to this version. Tests verifying the implementation are included in `openraft::testing::log::suite::Suite`. - Fixes: databendlabs#1261
Key log IDs represent the first log IDs proposed by each Leader. These IDs enable Openraft to efficiently access log IDs at each index with a succinct storage. Previously, key log IDs were obtained using a binary-search-like algorithm through `RaftLogReader`. This commit introduces the `RaftLogReader::get_key_log_ids()` method, allowing implementations to directly return a list of key log IDs if the `RaftLogStorage` can provide them. For backward compatibility, a default implementation using the original binary-search method is provided. No application changes are required when upgrading to this version. Tests verifying the implementation are included in `openraft::testing::log::suite::Suite`. - Fixes: databendlabs#1261
Key log IDs represent the first log IDs proposed by each Leader. These IDs enable Openraft to efficiently access log IDs at each index with a succinct storage. Previously, key log IDs were obtained using a binary-search-like algorithm through `RaftLogReader`. This commit introduces the `RaftLogReader::get_key_log_ids()` method, allowing implementations to directly return a list of key log IDs if the `RaftLogStorage` can provide them. For backward compatibility, a default implementation using the original binary-search method is provided. No application changes are required when upgrading to this version. Tests verifying the implementation are included in `openraft::testing::log::suite::Suite`. - Fixes: databendlabs#1261
Key log IDs represent the first log IDs proposed by each Leader. These IDs enable Openraft to efficiently access log IDs at each index with a succinct storage. Previously, key log IDs were obtained using a binary-search-like algorithm through `RaftLogReader`. This commit introduces the `RaftLogReader::get_key_log_ids()` method, allowing implementations to directly return a list of key log IDs if the `RaftLogStorage` can provide them. For backward compatibility, a default implementation using the original binary-search method is provided. No application changes are required when upgrading to this version. Tests verifying the implementation are included in `openraft::testing::log::suite::Suite`. - Fixes: databendlabs#1261
Currently, when
openraft
starts, it scans the entire log with random accesses to find key log IDs where the leader changed. However, this information may be already available in other state machine metadata (as it is in our case), so it can be provided toopenraft
by the state machine implementation, greatly reducing the effort finding key log IDs.My suggestion is to add a trait method to provide key log IDs and default-implement it with the current search algorithm. If the implementation of the state machine has a better way to provide key log IDs, then it can override the method and provide them directly.
The text was updated successfully, but these errors were encountered: