[BUG] webflux中SlotChainBuilder实例化异常后客户端被无限阻塞

オープン
#3,488 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
java
領域
api, backend

調査の方向性

SentinelReactorSubscriber.entryWhenSubscribed() から始め、issue に示されているカスタム SlotChainBuilder を使って sentinel-webflux-example で失敗を再現します。RuntimeException が Spring WebFlux と DefaultErrorWebExceptionHandler を通じてどのように伝播するかを確認します。クライアントリクエストがブロックされたままにならず、例外が処理された状態で終了し、logging またはエラーの伝播によって失敗を確認できれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Issue Description

Type: bug report

Describe what happened

在spring-webflux中使用sentinel
请求过程中实例化SlotChainBuilder报错后DefaultErrorWebExceptionHandler无法正常处理异常并且不会输出任何日志,客户端请求被无限阻塞.
原因是SentinelReactorSubscriber的entryWhenSubscribed()方法只处理了BlockException异常

private void entryWhenSubscribed() {
        ContextConfig sentinelContextConfig = this.entryConfig.getContextConfig();
        if (sentinelContextConfig != null) {
            ContextUtil.enter(sentinelContextConfig.getContextName(), sentinelContextConfig.getOrigin());
        }

        try {
            AsyncEntry entry = SphU.asyncEntry(this.entryConfig.getResourceName(), this.entryConfig.getResourceType(), this.entryConfig.getEntryType(), this.entryConfig.getAcquireCount(), this.entryConfig.getArgs());
            this.currentEntry = entry;
            this.actual.onSubscribe(this);
        } catch (BlockException ex) {
            this.entryExited.set(true);
            this.cancel();
            this.actual.onSubscribe(this);
            this.actual.onError(ex);
        } finally {
            if (sentinelContextConfig != null) {
                ContextUtil.exit();
            }

        }

    }
Describe what you expected to happen
How to reproduce it (as minimally and precisely as possible)
  1. 使用sentinel示例项目sentinel-webflux-example
  2. 配置com.alibaba.csp.sentinel.slotchain.SlotChainBuilder的自定义实现
public class TestBuilder extends DefaultSlotChainBuilder {

    @Override
    public ProcessorSlotChain build() {
        ProcessorSlotChain chain = super.build();
        if(1==1){
            // 强制抛出异常
            throw new RuntimeException();
        }
        return chain;
    }
}
Tell us your environment

jdk21、spring-webflux:3.2.9

Anything else we need to know?

entryWhenSubscribed()方法中处理包括BlockException的所有异常,问题解决

主要言語
Java
スター
23.1k
フォーク
8.1k
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

alibaba/Sentinel のほかの issue

alibaba/Sentinel の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。