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

Benchmark test problem #101

Closed
fangyincheng opened this issue Jun 24, 2019 · 1 comment · Fixed by #106
Closed

Benchmark test problem #101

fangyincheng opened this issue Jun 24, 2019 · 1 comment · Fixed by #106

Comments

@fangyincheng
Copy link
Contributor

What happened:

There are these problems, when high concurrency and continuous stress testing:

  • 'read tcp io timeout' is frequent
  • High CPU and memory footprint

What you expected to happen:

How to reproduce it (as minimally and precisely as possible):

Anything else we need to know?:

@AlexStocks
Copy link
Contributor

After search codes, its key problem is as following:

func (p *RpcClientPackageHandler) Read(ss getty.Session, data []byte) (interface{}, int, error) {
    p.client.pendingLock.RLock()
    defer p.client.pendingLock.RUnlock()
    pkg := &DubboPackage{}

    buf := bytes.NewBuffer(data)
    err := pkg.Unmarshal(buf, p.client)
}

func (p *DubboPackage) Unmarshal(buf *bytes.Buffer, opts ...interface{}) error {
    if len(opts) != 0 { // for client
            pendingRsp := client.GetPendingResponse(SequenceType(p.Header.ID))
    }
}

func (c *Client) GetPendingResponse(seq SequenceType) *PendingResponse {
    c.pendingLock.RLock()
    defer c.pendingLock.RUnlock()

    return c.pendingResponses[SequenceType(seq)]
}

The problem is that you can not use RWMutex.Lock again before releasing it by RWMutex.Unlock referring from sync: document that double RLock isn't safe:

If a goroutine has locked RWMutex for reading, it must not expect this,
or any other goroutine to be able to lock RWMutex for reading until the
first read lock is released. In particular, this prohibits recursive read
locking. The restriction is due to fairness properties: to ensure that
the lock eventually becomes available, a blocked Lock call excludes new
readers from acquiring the lock.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants