-
Notifications
You must be signed in to change notification settings - Fork 43
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
refactor: Make rootstore require Batching and TxnDatastore #940
Conversation
@@ -431,7 +420,6 @@ func (vf *VersionedFetcher) getDAGNode(c cid.Cid) (*dag.ProtoNode, error) { | |||
} | |||
|
|||
func (vf *VersionedFetcher) Close() error { | |||
vf.store.Discard(vf.ctx) | |||
if err := vf.root.Close(); err != nil { | |||
return err | |||
} |
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.
thought: I'm not quite sure if there are any negative impact to that change. What I do know is that keeping it there cause a Unclosed iterator at time of Txn.Discard
error.
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.
I think its OK to remove this, likely here accidentally since the vf.store
is a transaction that isn't "owned" by the VersionFetcher, so I don't think it should be responsbile to Discard it.
I am intrigued why its suddenly causing this issue.
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.
It did this when trying to switch to a transactional datastore when using the old map db. If I add it back now it works fine. I'll leave it out though as like you mentioned, it was probably added there by accident.
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.
Code change is simple and I am happy with it, but this is a new restriction on Defra and should be approved by John (product-decision, not technical)
f60e17c
to
01ffc86
Compare
Codecov Report
@@ Coverage Diff @@
## develop #940 +/- ##
===========================================
+ Coverage 57.73% 57.77% +0.04%
===========================================
Files 171 172 +1
Lines 19478 19455 -23
===========================================
- Hits 11246 11241 -5
+ Misses 7239 7225 -14
+ Partials 993 989 -4
|
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.
LGTM.
Some small notes/questions. Most notably in the db/db_test.go
we prob want to keep the badger inmemory store for those tests (or both)
@@ -431,7 +420,6 @@ func (vf *VersionedFetcher) getDAGNode(c cid.Cid) (*dag.ProtoNode, error) { | |||
} | |||
|
|||
func (vf *VersionedFetcher) Close() error { | |||
vf.store.Discard(vf.ctx) | |||
if err := vf.root.Close(); err != nil { | |||
return err | |||
} |
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.
I think its OK to remove this, likely here accidentally since the vf.store
is a transaction that isn't "owned" by the VersionFetcher, so I don't think it should be responsbile to Discard it.
I am intrigued why its suddenly causing this issue.
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.
Got to run, so submitting a few comments now
@@ -208,20 +208,19 @@ func (t *basicTxn) Commit(ctx context.Context) error { | |||
if t.discarded { | |||
return ErrTxnDiscarded | |||
} | |||
if t.readOnly { | |||
return ErrReadOnlyTxn |
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.
question: My brain is blanking here now - why are you removing this error?
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.
Because our collection api does a commit (c.commitImplicitTxn
) on Get
which is probably used to discard the transaction but nonetheless expects no errors of committing a read only transaction. Committing on a read only transaction now simply discards the transaction without error.
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.
Do we have any (other) protection against mutations made during a read only transaction?
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.
The actual Put
method checks if its readonly before doing the operation.
The commitImplicitTxn
is unrelated to this kind of stuff tho. Not sure how I missed this line, its def not an error to Commit
a readonly transaction, its just basically a no-op.
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.
Looks good! I really think DEFRA_IN_MEMORY needs to be added to the CI tests though
@@ -171,8 +171,6 @@ func TestTransactionalCreationAndLinkingOfRelationalDocumentsForward(t *testing. | |||
}, | |||
}, | |||
}, | |||
|
|||
DisableMapStore: true, |
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.
praise: Didnt realise we had so many of these now 😅 Really nice to lose them
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.
😄
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.
💯
f05a856
to
dea44f8
Compare
7617f37
to
4df2b24
Compare
Height is thread safe and Len isn’t.
…work#940) Relevant issue(s) Resolves sourcenetwork#683 Description This PR change the requirement for our supported datastore to implement both ds.Batching and ds.TxnDatastore. This means that the map datastore is no longer supported.
Relevant issue(s)
Resolves #683
Description
This PR change the requirement for our supported datastore to implement both
ds.Batching
andds.TxnDatastore
. This means that the map datastore is no longer supported.Tasks
How has this been tested?
make test
Specify the platform(s) on which this was tested: