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

conn: add write timeout for conn which receive a kill signal #44010

Closed
wants to merge 2 commits into from

Conversation

AilinKid
Copy link
Contributor

What problem does this PR solve?

Issue Number: close #44009

Problem Summary:

What is changed and how it works?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

add write timeout for conn which receive a kill signal

Signed-off-by: AilinKid <314806019@qq.com>
@ti-chi-bot
Copy link

ti-chi-bot bot commented May 19, 2023

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • Defined2014
  • wshwsh12

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/needs-triage-completed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels May 19, 2023
Signed-off-by: AilinKid <314806019@qq.com>
@ti-chi-bot ti-chi-bot bot added needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. and removed do-not-merge/needs-triage-completed labels May 19, 2023
@ti-chi-bot ti-chi-bot bot added the status/LGT1 Indicates that a PR has LGTM 1. label May 19, 2023
@ti-chi-bot ti-chi-bot bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels May 19, 2023
@AilinKid
Copy link
Contributor Author

/merge

@ti-chi-bot
Copy link

ti-chi-bot bot commented May 19, 2023

This pull request has been accepted and is ready to merge.

Commit hash: 776747c

@ti-chi-bot ti-chi-bot bot added the status/can-merge Indicates a PR has been approved by a committer. label May 19, 2023
@Defined2014
Copy link
Contributor

/hold

@ti-chi-bot ti-chi-bot bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 19, 2023
@AilinKid
Copy link
Contributor Author

AilinKid commented May 22, 2023

for loop {
    // drain the select result
    execStmt.Next(ctx, chunk) {
        Next(executor)
        kill singal check
    }
    dump the chunk to conn {
        start := time.now()
        dump chunk to data
        write(data) to conn
        write-resp += time.since(start)
    }
}

##### an explanation for slow-log queries with a long write-resp time:
we couldn't say a statement skip out of all the kill singal check, since Next calling is in 
the unit of a chunk(1024 row). If a statement has a long write-resp in slow log, that means a
accumulated long write-time of these data to conn.


##### an explanation for problem queries that couldn't be killed:
When it comes to queries that can't be killed, the only guess is that we don't have a second 
Next loop check for a kill signal and exits as an interrupt, and the dump time keeps 
getting stuck this time around. 

We need a wakeable write data implementation when a blocking write data has occurred.

@AilinKid
Copy link
Contributor Author

AilinKid commented May 22, 2023

We have interspersed the Next interface call in the interval of write data with chunk as the unit to realize the detection of kill signal, but the blocking problem of write-data itself is still an important solution to this problem, and default timeout may not be a good solution way of blocking. Considering that this problem only occurs when the network is extremely poor, temporarily close if there is no elegant solution. (chinese explanation: 我们已经在以 chunk 为单元的 write data 的间隔中穿插了 Next 接口调用来实现 kill signal 的检测,但是 write-data 自身的阻塞问题是仍然是这个问题的重要解,default timeout 可能并不是一个好的解除阻塞的方式,考虑到这问题只有在网络极差的情况下才发生,没有优雅解法的情况下暂时close)

@AilinKid AilinKid closed this May 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kill statement can't work and write result to conn takes a lot of time
3 participants