jcasbin / redis-watcher

Redis watcher for jCasbin
https://github.com/casbin/jcasbin
Apache License 2.0
4 stars 12 forks source link

fix: fix bug that "Redis sub exception occurs and sync becomes invalid" #30

Closed yu-hailong closed 2 years ago

yu-hailong commented 2 years ago

Fix: https://github.com/jcasbin/redis-watcher/issues/29

casbin-bot commented 2 years ago

@tangyang9464 @imp2002 please review

CLAassistant commented 2 years ago

CLA assistant check
All committers have signed the CLA.

yu-hailong commented 2 years ago

LGTM! Thanks.

It may be that server setting up the timeout not zero, it means after one period connection is disposed or closed. I'm not sure if a connect which is in subscribe will be closed by server, it's a guess.

Solution is set timeout on server to 0.

And Resubscribe is necessary, when an exception is thrown just like this or when redis is restart. Thank you for Issue and PR.

For product redis server, timeout = 0 is not good, because maybe some bugs cause redis's link increase until resource exhaust。

and maybe some nework problem problem cause redis-connect down。

so I think, some method should be considered while sub-connect is closed

hsluoyz commented 2 years ago

@yu-hailong plz fix:

image

codecov[bot] commented 2 years ago

Codecov Report

Merging #30 (87a05c5) into master (519931b) will decrease coverage by 4.78%. The diff coverage is 50.00%.

@@            Coverage Diff             @@
##           master      #30      +/-   ##
==========================================
- Coverage   94.44%   89.65%   -4.79%     
==========================================
  Files           3        3              
  Lines          54       58       +4     
  Branches        3        3              
==========================================
+ Hits           51       52       +1     
- Misses          1        4       +3     
  Partials        2        2              
Impacted Files Coverage Δ
src/main/java/org/casbin/watcher/SubThread.java 73.68% <50.00%> (-12.99%) :arrow_down:

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 519931b...87a05c5. Read the comment docs.

github-actions[bot] commented 2 years ago

:tada: This PR is included in version 1.4.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: