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

Splitstore: add support for protecting out of chain references in the blockstore #6777

Merged
merged 4 commits into from
Jul 20, 2021

Conversation

vyzo
Copy link
Contributor

@vyzo vyzo commented Jul 17, 2021

This adds a mechanism for protecting out-of-chain references during compaction (and in the future gc).

The problem is that we actually have live references in the blockstore, that are not (yet) reachable from the chain. This arises from pending messages in the mpool, and can result in archiving/discarding such messages during compaction even though they are live.

The solution is to do what garbage collecting programming languages do since the beginning of time: add a hook to protect external references.
The hook is hooked[sic] to the mpool through DI.

Open question: are there other such references that need to be protected?

@vyzo vyzo requested review from magik6k, Stebalien and raulk July 17, 2021 17:46
@vyzo
Copy link
Contributor Author

vyzo commented Jul 20, 2021

Following sync discussion with @Stebalien , we decided that we shouldn't indirect through the chainstore and instead hook the gc hooks directly through DI.
Less invasive this way, even if it is more indirect.

@vyzo vyzo force-pushed the feat/splitstore-protect branch from 5ef95ef to 0fb966d Compare July 20, 2021 06:00
@vyzo vyzo requested a review from a team as a code owner July 20, 2021 06:00
@vyzo vyzo force-pushed the feat/splitstore-protect branch from 0fb966d to c47fce8 Compare July 20, 2021 06:02
Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some nits but this is much nicer.

@@ -58,7 +58,7 @@ func ChainBlockService(bs dtypes.ExposedBlockstore, rem dtypes.ChainBitswap) dty
return blockservice.New(bs, rem)
}

func MessagePool(lc fx.Lifecycle, mpp messagepool.Provider, ds dtypes.MetadataDS, nn dtypes.NetworkName, j journal.Journal) (*messagepool.MessagePool, error) {
func MessagePool(lc fx.Lifecycle, mpp messagepool.Provider, ds dtypes.MetadataDS, nn dtypes.NetworkName, j journal.Journal, protector dtypes.GCReferenceProtector) (*messagepool.MessagePool, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't really a dependency, so I assume this would be a separate "invoke" step (next to the splitstore step). But I don't have strong opinions.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I have strong opinions. Just not about this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could do it with an invoke step, but doing it here avoids all possible races I think.
No strong opinions on this either.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

basically I want to make sure that AddProtector invocations all happen before Start in the splitstore.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume that Start gets called from a hook, which runs after all invokes (IIRC).

chain/messagepool/messagepool.go Outdated Show resolved Hide resolved
@vyzo
Copy link
Contributor Author

vyzo commented Jul 20, 2021

@vyzo vyzo mentioned this pull request Jul 20, 2021
@Stebalien Stebalien merged commit 591320d into master Jul 20, 2021
@Stebalien Stebalien deleted the feat/splitstore-protect branch July 20, 2021 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants