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

Added support for fromBlock when generating eventservice cache keys #184

Merged
merged 8 commits into from
May 10, 2022

Conversation

jimthematrix
Copy link
Contributor

@jimthematrix jimthematrix commented Aug 5, 2021

The current cache key only takes into account the channel ID, which means if I have a different fromBlock number, or chaincode Id with a subsequent RegisterBlockEvent() call, it would not take effect because the previous event service will be returned from the cache lookup.

@jimthematrix jimthematrix requested a review from a team as a code owner August 5, 2021 22:40
@codecov
Copy link

codecov bot commented Aug 5, 2021

Codecov Report

Merging #184 (2ae5ea6) into main (e866365) will increase coverage by 0.06%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #184      +/-   ##
==========================================
+ Coverage   76.15%   76.21%   +0.06%     
==========================================
  Files         193      193              
  Lines       14077    14098      +21     
==========================================
+ Hits        10720    10745      +25     
+ Misses       2388     2385       -3     
+ Partials      969      968       -1     
Impacted Files Coverage Δ
pkg/client/channel/chclientrun_std.go 100.00% <ø> (ø)
pkg/fabsdk/fabsdk_std.go 100.00% <ø> (ø)
pkg/client/event/event.go 85.00% <100.00%> (+6.05%) ⬆️
pkg/client/event/opts.go 100.00% <100.00%> (ø)
pkg/fab/events/deliverclient/opts.go 100.00% <100.00%> (ø)
pkg/fabsdk/provider/chpvdr/cachekey.go 84.00% <100.00%> (+7.80%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e866365...2ae5ea6. Read the comment docs.

@kopaygorodsky
Copy link
Contributor

Hey @jimthematrix, are you going to continue working on this PR (fix tests, code coverage)? I've stumbled on this issue as well and would like to help if this PR is stale.

@jimthematrix
Copy link
Contributor Author

@kopaygorodsky thanks for offering to help, I haven't been able to get back to this one. if you are able to spare some cycles on the tests that'd be much appreciated!

@stale
Copy link

stale bot commented Mar 30, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Mar 30, 2022
@stale stale bot removed the stale label May 6, 2022
@jimthematrix jimthematrix force-pushed the eventservice-cache-key branch from e59c782 to 92bc40a Compare May 6, 2022 21:35
Signed-off-by: Jim Zhang <[email protected]>
@jimthematrix jimthematrix force-pushed the eventservice-cache-key branch from ec18302 to 31fb7c4 Compare May 9, 2022 19:40
@bstasyszyn bstasyszyn merged commit 7a94fbc into hyperledger:main May 10, 2022
@jimthematrix jimthematrix deleted the eventservice-cache-key branch May 10, 2022 18:39
@kopaygorodsky
Copy link
Contributor

@bstasyszyn hey, this PR raised a problem related to the lazycache component. Each event client with a different starting block number is a new entry in the cache. It has some idling timeout and then calls finalizer which closes the connection and resets Ref to nil, but the key in the cache stays. One of my environments has very often reconnections with increasing block number param each time so in a week it resulted in 200Mb of keys in the cache.
I see three possible solutions to this problem:

  • IOC of the context.ChannelProvider in the constructor of the event client. It gives the user ability to create channel context and close it manually. On CloseContext all cached are cleaned.
  • By fixing the reset mode of the Reference. Put the link of the Cache into the Reference so it can clean up its key in the handleExpiration method.
  • Add the DeleteOnlyKey method to the cache, so it just deletes the key without calling close(). In that way a callback with that method can be put into a custom finalizer.

@kopaygorodsky
Copy link
Contributor

@bstasyszyn

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.

3 participants