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

Grpc Adapter entry关闭问题 #396

Closed
fingthinking opened this issue Jan 8, 2019 · 2 comments
Closed

Grpc Adapter entry关闭问题 #396

fingthinking opened this issue Jan 8, 2019 · 2 comments
Labels
kind/question Category issues related to questions or problems

Comments

@fingthinking
Copy link

代码镇楼:

 public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall(MethodDescriptor<ReqT, RespT> methodDescriptor,
                                                               CallOptions callOptions, Channel channel) {
        String resourceName = methodDescriptor.getFullMethodName();
        Entry entry = null;
        try {
            entry = SphU.entry(resourceName, EntryType.OUT);
            // Allow access, forward the call.
            return new ForwardingClientCall.SimpleForwardingClientCall<ReqT, RespT>(
                channel.newCall(methodDescriptor, callOptions)) {
                @Override
                public void start(Listener<RespT> responseListener, Metadata headers) {
                    super.start(new SimpleForwardingClientCallListener<RespT>(responseListener) {
                        @Override
                        public void onReady() {
                            super.onReady();
                        }

                        @Override
                        public void onClose(Status status, Metadata trailers) {
                            super.onClose(status, trailers);
                            // Record the exception metrics.
                            if (!status.isOk()) {
                                recordException(status.asRuntimeException());
                            }
                        }
                    }, headers);
                }

                @Override
                public void cancel(@Nullable String message, @Nullable Throwable cause) {
                    super.cancel(message, cause);
                    // Record the exception metrics.
                    recordException(cause);
                }
            };
        } catch (BlockException e) {
            // Flow control threshold exceeded, block the call.
            return new ClientCall<ReqT, RespT>() {
                @Override
                public void start(Listener<RespT> responseListener, Metadata headers) {
                    responseListener.onClose(FLOW_CONTROL_BLOCK, new Metadata());
                }

                @Override
                public void request(int numMessages) {

                }

                @Override
                public void cancel(@Nullable String message, @Nullable Throwable cause) {

                }

                @Override
                public void halfClose() {

                }

                @Override
                public void sendMessage(ReqT message) {

                }
            };
        } finally {
            if (entry != null) {
                entry.exit();
            }
        }
    }

grpc adapter中在finally方法中调用的entry.exit(), 那么问题来了,先exit了,然后在cancel方法中recordException,此时entry已经退出了,那么这个exception将不能被正确的记录。暂时没想到什么处理办法~~~惆怅

@sczyh30 sczyh30 added the kind/question Category issues related to questions or problems label Jan 8, 2019
@sczyh30
Copy link
Member

sczyh30 commented Jan 8, 2019

Hi, this is a known issue. There's already a PR pending. You can refer to: #289, #291

@fingthinking
Copy link
Author

@sczyh30 thank u~~

CST11021 pushed a commit to CST11021/Sentinel that referenced this issue Nov 3, 2021
…r transactional message (alibaba#397)

* Use separate threadpool and add monitor tools for transaction

* Modify log level
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/question Category issues related to questions or problems
Projects
None yet
Development

No branches or pull requests

2 participants