Skip to content
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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Start implementing auto-repair #107

wants to merge 1 commit into from

Conversation

albe
Copy link
Owner

@albe albe commented May 31, 2020

No description provided.

@albe albe added this to To do in 0.8 Jun 27, 2020
@albe albe mentioned this pull request Jun 27, 2020
* @private
*/
checkTornWrite() {
let position = this.storage.length;
Copy link
Owner Author

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.

Copy link
Owner Author

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 => {
Copy link
Owner Author

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 });
Copy link
Owner Author

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

@albe
Copy link
Owner Author

albe commented May 16, 2021

This needs to be rewritten to only deal with unfinished commits as the torn writes has already been covered by #155

@albe albe removed this from To do in 0.8 May 17, 2021
@albe albe added this to To do in 0.9 May 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
0.9
To do
Development

Successfully merging this pull request may close these issues.

None yet

1 participant