Sentinel icon indicating copy to clipboard operation
Sentinel copied to clipboard

线程限制产生竞态条件的一种规避方式

Open manzhizhen opened this issue 7 years ago • 17 comments

Describe what this PR does / why we need it

详细描述见: https://github.com/alibaba/Sentinel/issues/59 一种解决方案:使用信号量+ThreadLocal的方式,保证了原子性,也保证了能在接下来的Slot的处理过程中能利用到前面的结果。

该方式加强了线程限制的准确性,并保持原有的逻辑不变。

Does this pull request fix one issue?

Describe how you did it

Describe how to verify it

Special notes for reviews

manzhizhen avatar Aug 20 '18 16:08 manzhizhen

Codecov Report

:exclamation: No coverage uploaded for pull request base (master@9c268bd). Click here to learn what that means. The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master      #76   +/-   ##
=========================================
  Coverage          ?   40.43%           
  Complexity        ?     1314           
=========================================
  Files             ?      297           
  Lines             ?     8591           
  Branches          ?     1156           
=========================================
  Hits              ?     3474           
  Misses            ?     4693           
  Partials          ?      424

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 9c268bd...5f9f120. Read the comment docs.

codecov-io avatar Aug 20 '18 16:08 codecov-io

ping @manzhizhen Conflict happens after merging a previous commit. Please rebase the branch against master and push it back again. Thanks a lot.

OK, I will deal with it later.

manzhizhen avatar Nov 05 '18 10:11 manzhizhen

ping @manzhizhen Conflict happens after merging a previous commit. Please rebase the branch against master and push it back again. Thanks a lot.

Already submitted, in integration testing

manzhizhen avatar Nov 05 '18 12:11 manzhizhen

ping @manzhizhen Conflict happens after merging a previous commit. Please rebase the branch against master and push it back again. Thanks a lot.

ok,I do it later.

manzhizhen avatar Dec 07 '18 10:12 manzhizhen

ping @manzhizhen Conflict happens after merging a previous commit. Please rebase the branch against master and push it back again. Thanks a lot.

I do it now!!

manzhizhen avatar Dec 09 '18 02:12 manzhizhen

Ping @manzhizhen . Conflict happens after merging a previous commit. Please rebase the branch against master and push it back again. Thanks a lot.

sentinel-bot avatar Jan 18 '19 09:01 sentinel-bot

Ping @manzhizhen . Conflict happens after merging a previous commit. Please rebase the branch against master and push it back again. Thanks a lot.

sentinel-bot avatar Jan 18 '19 10:01 sentinel-bot

Ping @manzhizhen . Conflict happens after merging a previous commit. Please rebase the branch against master and push it back again. Thanks a lot.

sentinel-bot avatar Jan 18 '19 10:01 sentinel-bot

Ping @manzhizhen . Conflict happens after merging a previous commit. Please rebase the branch against master and push it back again. Thanks a lot.

sentinel-bot avatar Jan 18 '19 10:01 sentinel-bot

Ping @manzhizhen . Conflict happens after merging a previous commit. Please rebase the branch against master and push it back again. Thanks a lot.

sentinel-bot avatar Jan 18 '19 10:01 sentinel-bot

Ping @manzhizhen . Conflict happens after merging a previous commit. Please rebase the branch against master and push it back again. Thanks a lot.

sentinel-bot avatar Jan 18 '19 10:01 sentinel-bot

ping @manzhizhen Conflict happens after merging a previous commit. Please rebase the branch against master and push it back again. Thanks a lot.

ok,I do it.

manzhizhen avatar Jan 18 '19 10:01 manzhizhen

ping @manzhizhen Conflict happens after merging a previous commit. Please rebase the branch against master and push it back again. Thanks a lot.

ok!!

manzhizhen avatar Jan 18 '19 11:01 manzhizhen

ping @manzhizhen Conflict happens after merging a previous commit. Please rebase the branch against master and push it back again. Thanks a lot.

ok

manzhizhen avatar Mar 15 '19 02:03 manzhizhen

ping @manzhizhen Conflict happens after merging a previous commit. Please rebase the branch against master and push it back again. Thanks a lot.

ok,I will do it

manzhizhen avatar Jun 05 '19 02:06 manzhizhen

Codecov Report

Merging #76 into master will decrease coverage by 1.31%. The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##             master      #76      +/-   ##
============================================
- Coverage     41.75%   40.43%   -1.32%     
+ Complexity     1377     1314      -63     
============================================
  Files           304      297       -7     
  Lines          8766     8591     -175     
  Branches       1182     1156      -26     
============================================
- Hits           3660     3474     -186     
- Misses         4660     4693      +33     
+ Partials        446      424      -22     
Impacted Files Coverage Δ Complexity Δ
...apter/gateway/common/param/GatewayParamParser.java 0.00% <0.00%> (-68.26%) 0.00% <0.00%> (-17.00%)
...va/com/alibaba/csp/sentinel/init/InitExecutor.java 13.15% <0.00%> (-47.37%) 2.00% <0.00%> (-4.00%)
...src/main/java/com/alibaba/csp/sentinel/Tracer.java 0.00% <0.00%> (-31.15%) 0.00% <0.00%> (-12.00%)
...slots/statistic/StatisticSlotCallbackRegistry.java 22.22% <0.00%> (-22.23%) 3.00% <0.00%> (-2.00%)
...ba/csp/sentinel/slots/statistic/StatisticSlot.java 52.38% <0.00%> (-14.29%) 10.00% <0.00%> (-3.00%)
...java/com/alibaba/csp/sentinel/util/AssertUtil.java 13.33% <0.00%> (-13.34%) 2.00% <0.00%> (-1.00%)
...inel/slots/block/flow/param/ParamFlowRuleUtil.java 50.87% <0.00%> (-10.67%) 20.00% <0.00%> (-10.00%)
.../java/com/alibaba/csp/sentinel/util/SpiLoader.java 0.00% <0.00%> (-8.65%) 0.00% <0.00%> (-2.00%)
...ateway/common/api/GatewayApiDefinitionManager.java 27.94% <0.00%> (-5.89%) 6.00% <0.00%> (-1.00%)
...csp/sentinel/slots/block/flow/FlowRuleChecker.java 45.45% <0.00%> (-4.55%) 16.00% <0.00%> (-5.00%)
... and 20 more

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 ee38587...5f9f120. Read the comment docs.

codecov-commenter avatar Jun 10 '20 02:06 codecov-commenter

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


yizhenqiang seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

CLAassistant avatar Jun 12 '20 07:06 CLAassistant

The PR has remained open for an extended period and has accumulated significant merge conflicts. We will therefore close it temporarily as the main development branch for Sentinel has now transitioned to the 1.8 branch. New contributions are welcome with PRs based on the 1.8 branch.

LearningGp avatar Sep 04 '25 08:09 LearningGp