Conversation
| * @private | ||
| */ | ||
| checkTornWrite() { | ||
| let position = this.storage.length; |
There was a problem hiding this comment.
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.
| const indexes = []; | ||
|
|
||
| let leastConsistentEntry = this.storage.index.lastEntry; | ||
| this.storage.forEachSecondaryIndex(index => { |
There was a problem hiding this comment.
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.
| }; | ||
| for (let event of events) { | ||
| const eventMetadata = Object.assign({ commitId, committedAt }, metadata, { commitVersion, streamVersion }); | ||
| const eventMetadata = Object.assign({ commitId, committedAt }, metadata, { commitVersion, commitSize, streamVersion }); |
|
This needs to be rewritten to only deal with unfinished commits as the torn writes has already been covered by #155 |
No description provided.