-
Notifications
You must be signed in to change notification settings - Fork 750
DRAFT: Demonstrating fallible index traits #7790
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
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
629eb95
to
b0a9250
Compare
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.
All in all this looks great. I do think there are some minor codestyle issues and some helpers missing for all the tests which unwrap by default now.
I also think Yuya should take a look at it since he's the expert of that part of the codebase.
Thank you @PhilipMetzger! I'll fix up these items in their respective changes. |
fc935d9
to
4f53071
Compare
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.
With some last minor nits this looks good enough to split into 2/3 smaller PRs because this is large and it reduces reviewer time. I'll also let Yuya be the judge of your more functional rewrites of some filter(...).map(...)
calls into filter_map
.
This way we match how errors are organized for the other storage traits, and we allow for networked implementations of `Index::all_heads_for_gc` to return I/O errors.
This way we match how the errors are organized for other storage traits.
By using a type alias, we match how `Backend` and `OpStore` traits organize their errors. This will be useful as we progressively convert more methods on `Index`, `MutableIndex`, `ReadonlyIndex`, and `ChangeIdIndex` traits to return `Result<T, IndexError>` in order to support networked implementations which can produce I/O failures.
By introducing `IndexStoreResult`, we follow the pattern used by other storage traits: `BackendResult`, `OpStoreResult`, and `IndexResult`.
4f53071
to
36383b1
Compare
36383b1
to
1081d57
Compare
@yuja @martinvonz @PhilipMetzger Thanks for your help everyone! I believe I've applied all of the suggestions above. I think we can probably start shifting to PRs at this point -- going to close out this draft. I put the first few changes are in #7799. |
This is part of a series of changes to make most methods on index traits (i.e. `ChangeIdIndex`, `MutableIndex`, `ReadonlyIndex`, `Index`) fallible. This will enable networked implementations of these traits, which can produce I/O errors during operation. See jj-vcs#7790 for more information.
This is part of a series of changes to make most methods on index traits (i.e. `ChangeIdIndex`, `MutableIndex`, `ReadonlyIndex`, `Index`) fallible. This will enable networked implementations of these traits, which can produce I/O errors during operation. See jj-vcs#7790 for more information.
This is part of a series of changes to make most methods on index traits (i.e. `ChangeIdIndex`, `MutableIndex`, `ReadonlyIndex`, `Index`) fallible. This will enable networked implementations of these traits, which can produce I/O errors during operation. See jj-vcs#7790 for more information.
This is part of a series of changes to make most methods on index traits (i.e. `ChangeIdIndex`, `MutableIndex`, `ReadonlyIndex`, `Index`) fallible. This will enable networked implementations of these traits, which can produce I/O errors during operation. See jj-vcs#7790 for more information.
Hi everyone!
I'm not planning to submit this PR as is. I'm posting this to get some thoughts on this line of work, which converts most methods on
Index
,MutableIndex
,ReadonlyIndex
, andChangeIdIndex
to have fallible (i.e.Result
) return values. The motivation here is supporting distributed implementations of these index traits which might perform I/O during most operations. This way, implementers would not be forced to keep entire indices in memory. TheBackend
,OpStore
, andOpHeadsStore
storage traits already support distributed/network implementations, so these changes bring the*Index
traits in line with those three.If you look at the changes, note that I purposefully did not include a similar conversion of
ReadonlyIndex::start_modification()
-- that's because the consequences are quite a bit more involved than the other methods, due to causingWorkspaceCommandHelper::start_transaction()
to become fallible. From what I can tell, I think most distributed/network implementations of the storage traits would probably be able to get by without making this one fallible by using an interior mutability pattern. (I could go into more detail if that's helpful).FWIW:
IndexError
in addition toBackendError
), I erred toward sprinkling in a few more instances of the existing// TODO: indexing error shouldn't be a "BackendError"
Thanks!
Brian