-
Notifications
You must be signed in to change notification settings - Fork 4
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
Start implementing auto-repair #107
base: main
Are you sure you want to change the base?
Conversation
* @private | ||
*/ | ||
checkTornWrite() { | ||
let position = this.storage.length; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To fix torn writes (which should be a storage level concern) we need to infer the position from the actual documents in the storage rather than the information from the index. Hence the storage needs to read the last document of each partition and return the highest document header sequenceNumber.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #155
const indexes = []; | ||
|
||
let leastConsistentEntry = this.storage.index.lastEntry; | ||
this.storage.forEachSecondaryIndex(index => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: Updating secondary indexes is problematic, because they can fall back behind the primary index. However, we do not know if an index has actually fallen behind or if it just didn't match any later documents. This leads to the worst case of one secondary index only matching the first document written, but no other, which would mean the whole storage needs to be reindexed.
@@ -216,7 +307,7 @@ class EventStore extends EventEmitter { | |||
callback(commit); | |||
}; | |||
for (let event of events) { | |||
const eventMetadata = Object.assign({ commitId, committedAt }, metadata, { commitVersion, streamVersion }); | |||
const eventMetadata = Object.assign({ commitId, committedAt }, metadata, { commitVersion, commitSize, streamVersion }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already implemented as of #159
This needs to be rewritten to only deal with unfinished commits as the torn writes has already been covered by #155 |
No description provided.