Refactors the tracker to expose an interface and an implementation type. Decoupling these will let us inject new state/functionality transparently to the client function (like the iterator metrics for cerc-io/ipld-eth-state-snapshot#1).
Refactors the tracker to expose an interface and an implementation type. Decoupling these will let us inject new state/functionality transparently to the client function (like the iterator metrics for https://git.vdb.to/cerc-io/ipld-eth-state-snapshot/pulls/1).
telackey
was assigned by roysc2023-09-25 18:45:36 +00:00
Is it explicit anywhere that you must call CloseAndSave in order to close the channel, set running to false, etc?
What happens if you don't call that, but the iterator completes?
If we need to call it, I think the pattern:
tr := tracker.New(recoveryFile, NumIters)
defer tr.CloseAndSave() // <--- You must do this!
Needs to be documented explicitly somewhere (unless I am just missing something).
Is it explicit anywhere that you *must* call CloseAndSave in order to close the channel, set running to false, etc?
What happens if you don't call that, but the iterator completes?
If we need to call it, I think the pattern:
```
tr := tracker.New(recoveryFile, NumIters)
defer tr.CloseAndSave() // <--- You must do this!
```
Needs to be documented explicitly somewhere (unless I am just missing something).
If it's not called, it should just be sort of a leak. The channels won't be flushed or saved, but once all its iterators die, the tracker will still be gc'd. No critical consequences that I foresee, but I will document it.
If it's not called, it should just be sort of a leak. The channels won't be flushed or saved, but once all its iterators die, the tracker will still be gc'd. No critical consequences that I foresee, but I will document it.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Refactors the tracker to expose an interface and an implementation type. Decoupling these will let us inject new state/functionality transparently to the client function (like the iterator metrics for cerc-io/ipld-eth-state-snapshot#1).
@@ -145,1 +181,3 @@func (tr *Tracker) HaltAndDump() error {// CloseAndSave stops all tracked iterators and dumps their state to a file.// This closes the tracker, so adding a new iterator will fail.func (tr *TrackerImpl) CloseAndSave() error {Is it explicit anywhere that you must call CloseAndSave in order to close the channel, set running to false, etc?
What happens if you don't call that, but the iterator completes?
If we need to call it, I think the pattern:
Needs to be documented explicitly somewhere (unless I am just missing something).
If it's not called, it should just be sort of a leak. The channels won't be flushed or saved, but once all its iterators die, the tracker will still be gc'd. No critical consequences that I foresee, but I will document it.
@@ -175,3 +206,4 @@ret := it.NodeIterator.Next(descend)if !ret {it.tracker.RLock()Why not call
it.StopIterator()? I am always nervous about code that requires a precise locking scheme being duplicated multiple places.That's fair - I don't think we actually need StopIterator any more, so I will just delete it for now.