Code Monkey home page Code Monkey logo

Comments (23)

carlzhao avatar carlzhao commented on July 28, 2024

这里是不是没必要一直通过

msg := q.Dequeue() if msg == nil { break }

轮询有没有数据到达,在CallbackMessageQueue里面,使用一个channel在Enqueue有消息的时候,通知Dequeue取数据并返回,是不是就可以了?

from incubator-seata-go.

dk-lockdown avatar dk-lockdown commented on July 28, 2024

使用 channel 的话,如果 rpc stream 连接挂掉,定时任务往 channel 里放消息,会卡住程序

from incubator-seata-go.

dk-lockdown avatar dk-lockdown commented on July 28, 2024

有其他的任务的时候,这个 goroutine 会让出时间片,不会一直执行。要研究一下怎么优化它

from incubator-seata-go.

carlzhao avatar carlzhao commented on July 28, 2024

使用 channel 的话,如果 rpc stream 连接挂掉,定时任务往 channel 里放消息,会卡住程序

是说stream.Send报错吗?返回err 不是直接return掉了?

from incubator-seata-go.

Leadrive avatar Leadrive commented on July 28, 2024

@carlzhao 按你给的fix改了,CPU没有100%,但也是99%。:)

from incubator-seata-go.

Leadrive avatar Leadrive commented on July 28, 2024

把TC停掉,三个svc也基本把CPU占满了。

from incubator-seata-go.

dk-lockdown avatar dk-lockdown commented on July 28, 2024

因为要引入 grpc streaming 通信,grpc stream 的 gr 会一直去轮询有没有供发送的消息。尝试主动让出时间片,效果也不明显。

from incubator-seata-go.

carlzhao avatar carlzhao commented on July 28, 2024

@carlzhao 按你给的fix改了,CPU没有100%,但也是99%。:)

TC停掉,是因为连不上TC一直在空转,这是另一个锅,grpc.Dial没有通,但是没有返回err
你看下我这次的修复递交吧,carlzhao@8dd5a9b

from incubator-seata-go.

carlzhao avatar carlzhao commented on July 28, 2024

@carlzhao 按你给的fix改了,CPU没有100%,但也是99%。:)

TC停掉,是因为连不上TC一直在空转,这是另一个锅,grpc.Dial没有通,但是没有返回err
你看下我这次的修复递交吧,carlzhao@8dd5a9b

主要的修改在这里,去掉default,否则会一直空转

image

from incubator-seata-go.

Leadrive avatar Leadrive commented on July 28, 2024

@carlzhao 谢谢,晚点试下。

from incubator-seata-go.

dk-lockdown avatar dk-lockdown commented on July 28, 2024

@carlzhao 按你给的fix改了,CPU没有100%,但也是99%。:)

TC停掉,是因为连不上TC一直在空转,这是另一个锅,grpc.Dial没有通,但是没有返回err
你看下我这次的修复递交吧,carlzhao@8dd5a9b

主要的修改在这里,去掉default,否则会一直空转

image

这个解决问题吗,能的话提个 pr 吧

from incubator-seata-go.

dk-lockdown avatar dk-lockdown commented on July 28, 2024

错吗?返回err 不是直接return掉了?

是的,他直接 return 了,还有个异步重试的 gr 在往 branchMessages 里发消息,如果改成 channel 可能阻塞

from incubator-seata-go.

carlzhao avatar carlzhao commented on July 28, 2024

@carlzhao 按你给的fix改了,CPU没有100%,但也是99%。:)

TC停掉,是因为连不上TC一直在空转,这是另一个锅,grpc.Dial没有通,但是没有返回err
你看下我这次的修复递交吧,carlzhao@8dd5a9b

主要的修改在这里,去掉default,否则会一直空转
image

这个解决问题吗,能的话提个 pr 吧

能解决,我递交了一个pr,自测过tc和samples工程cpu消耗都降下来了

from incubator-seata-go.

dk-lockdown avatar dk-lockdown commented on July 28, 2024

@carlzhao 还有个问题,我想了一下是可以用 channel 的,这块是我想错了,刚测试了一下换 channel 也没问题。稍后我更新下代码。

from incubator-seata-go.

dk-lockdown avatar dk-lockdown commented on July 28, 2024

@carlzhao @Leadrive 试试 2.0.4-rc1 版本

from incubator-seata-go.

Leadrive avatar Leadrive commented on July 28, 2024

试了rc1,CPU降下来了,但测试发现sample回滚失败。
我在那边提交了一个issue,麻烦看看。

from incubator-seata-go.

Leadrive avatar Leadrive commented on July 28, 2024

WIN10,机器睡眠后,今天打开机器。3个svc又把CPU占满了。此时TC没开

INFO: 2021/09/19 08:14:14 [core] Subchannel Connectivity change to CONNECTING
INFO: 2021/09/19 08:14:14 [core] Subchannel picks a new address "localhost:8091" to connect
INFO: 2021/09/19 08:14:14 [core] pickfirstBalancer: UpdateSubConnState: 0xc0004ae110, {CONNECTING <nil>}
INFO: 2021/09/19 08:14:14 [core] Channel Connectivity change to CONNECTING
WARNING: 2021/09/19 08:14:16 [core] grpc: addrConn.createTransport failed to connect to {localhost:8091 localhost:8091 <nil> 0 <nil>}. Err: connection error: desc = "transport: Error while dialing dial tcp [::1]:8091: connectex: No connection could be made because the target machine actively refused it.". Reconnecting...
INFO: 2021/09/19 08:14:16 [core] Subchannel Connectivity change to TRANSIENT_FAILURE
INFO: 2021/09/19 08:14:16 [core] pickfirstBalancer: UpdateSubConnState: 0xc0004ae110, {TRANSIENT_FAILURE connection error: desc = "transport: Error while dialing dial tcp [::1]:8091: connectex: No connection could be made because the target machine actively refused it."}
INFO: 2021/09/19 08:14:16 [core] Channel Connectivity change to TRANSIENT_FAILURE

再打开TC,过几分钟连上TC后,CPU降下来了。看来没连上TC的情况,要考虑一下。

from incubator-seata-go.

dk-lockdown avatar dk-lockdown commented on July 28, 2024

WIN10,机器睡眠后,今天打开机器。3个svc又把CPU占满了。此时TC没开

INFO: 2021/09/19 08:14:14 [core] Subchannel Connectivity change to CONNECTING
INFO: 2021/09/19 08:14:14 [core] Subchannel picks a new address "localhost:8091" to connect
INFO: 2021/09/19 08:14:14 [core] pickfirstBalancer: UpdateSubConnState: 0xc0004ae110, {CONNECTING <nil>}
INFO: 2021/09/19 08:14:14 [core] Channel Connectivity change to CONNECTING
WARNING: 2021/09/19 08:14:16 [core] grpc: addrConn.createTransport failed to connect to {localhost:8091 localhost:8091 <nil> 0 <nil>}. Err: connection error: desc = "transport: Error while dialing dial tcp [::1]:8091: connectex: No connection could be made because the target machine actively refused it.". Reconnecting...
INFO: 2021/09/19 08:14:16 [core] Subchannel Connectivity change to TRANSIENT_FAILURE
INFO: 2021/09/19 08:14:16 [core] pickfirstBalancer: UpdateSubConnState: 0xc0004ae110, {TRANSIENT_FAILURE connection error: desc = "transport: Error while dialing dial tcp [::1]:8091: connectex: No connection could be made because the target machine actively refused it."}
INFO: 2021/09/19 08:14:16 [core] Channel Connectivity change to TRANSIENT_FAILURE

再打开TC,过几分钟连上TC后,CPU降下来了。看来没连上TC的情况,要考虑一下。

这种情况有什么好的优化方法没啊

from incubator-seata-go.

carlzhao avatar carlzhao commented on July 28, 2024

WIN10,机器睡眠后,今天打开机器。3个svc又把CPU占满了。此时TC没开

INFO: 2021/09/19 08:14:14 [core] Subchannel Connectivity change to CONNECTING
INFO: 2021/09/19 08:14:14 [core] Subchannel picks a new address "localhost:8091" to connect
INFO: 2021/09/19 08:14:14 [core] pickfirstBalancer: UpdateSubConnState: 0xc0004ae110, {CONNECTING <nil>}
INFO: 2021/09/19 08:14:14 [core] Channel Connectivity change to CONNECTING
WARNING: 2021/09/19 08:14:16 [core] grpc: addrConn.createTransport failed to connect to {localhost:8091 localhost:8091 <nil> 0 <nil>}. Err: connection error: desc = "transport: Error while dialing dial tcp [::1]:8091: connectex: No connection could be made because the target machine actively refused it.". Reconnecting...
INFO: 2021/09/19 08:14:16 [core] Subchannel Connectivity change to TRANSIENT_FAILURE
INFO: 2021/09/19 08:14:16 [core] pickfirstBalancer: UpdateSubConnState: 0xc0004ae110, {TRANSIENT_FAILURE connection error: desc = "transport: Error while dialing dial tcp [::1]:8091: connectex: No connection could be made because the target machine actively refused it."}
INFO: 2021/09/19 08:14:16 [core] Channel Connectivity change to TRANSIENT_FAILURE

再打开TC,过几分钟连上TC后,CPU降下来了。看来没连上TC的情况,要考虑一下。

这种情况有什么好的优化方法没啊

看下是不是这里导致的啊,我之前遇到的是连不上tc,这里就会循环err,然后continue,加行日志可以看到。

manager.rpcClient.BranchCommunicate(ctx)

这种可以在grpc连的时候就采用grpc.WithBlock()的方式保证连成功, 或是断连的时候,重新自动延迟重连

from incubator-seata-go.

dk-lockdown avatar dk-lockdown commented on July 28, 2024

@carlzhao ,要不你重新提个 pr。之前那个因为我已经改了就没合了。

from incubator-seata-go.

carlzhao avatar carlzhao commented on July 28, 2024

@dk-lockdown 下次跟别的一起修复下吧,我就不提pr了,没多少修改 ^_^

from incubator-seata-go.

dk-lockdown avatar dk-lockdown commented on July 28, 2024

@carlzhao 那我就关闭这个 issue 了哦

from incubator-seata-go.

carlzhao avatar carlzhao commented on July 28, 2024

好的

from incubator-seata-go.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.