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

database/sql: predictable request queue satisfaction #50358

Closed
wants to merge 1 commit into from
Closed

database/sql: predictable request queue satisfaction #50358

wants to merge 1 commit into from

Conversation

alzasr
Copy link

@alzasr alzasr commented Dec 27, 2021

change random satisfaction of the query queue to sequential

test simulate situation when query append faster that execution

Sitaution:

I have 2 source of query:

  • the first source generates queries often. These queries are not important and can be canceled by timeout. Contexts have timeout
  • the second source generates queryes less often. These queries are important and must be executed. Contexts dont have timeout;

Trouble:
The connection poll satisfied request by random. This behavior does not guarantee the execution of the request in a finite time. I am faced with situation an unlimited growth of latency.

I make test to demonstration my situation.

Results of random satisfaction:

delay(diff = 5m30.844350115s, expected = 1m58.8s, max = 7m29.644350115s), queue(len=298, max=1486, min=364, diff=1122)
sql_db_test.go:51: current delay 7m34.568549607s is 2 times greater than expected 1m59.6s
--- FAIL: TestDB_queryQueue (600.00s)

FAIL

Results of sequenced satisfaction:

delay(diff = 344.00638ms, expected = 1m58.8s, max = 1m59.14400638s), queue(len=298, max=1486, min=1189, diff=297)
--- PASS: TestDB_queryQueue (600.00s)
PASS

queue.len - length of request to execution
queue.max - max index of request from queue
queue.min - min index of request from queue
queue.diff = queue.max - queue.min
If queue.diff is much longer that queue.len then queue has request with big latency

delay.expected = (queue.len - 1) * appendReuqestDelay
delay.max - latency of older request
delay.diff = delay.max - delay.expected

Solution:
Change the connection behavior from random to sequenced.

change random satisfaction of the query queue to sequential

test simulate situation when query append faster that execution
@gopherbot
Copy link
Contributor

This PR (HEAD: 16d8742) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/go/+/374416 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link
Contributor

Message from Gopher Robot:

Patch Set 1:

Congratulations on opening your first change. Thank you for your contribution!

Next steps:
A maintainer will review your change and provide feedback. See
https://golang.org/doc/contribute.html#review for more info and tips to get your
patch through code review.

Most changes in the Go project go through a few rounds of revision. This can be
surprising to people new to the project. The careful, iterative review process
is our way of helping mentor contributors and ensuring that their contributions
have a lasting impact.

During May-July and Nov-Jan the Go project is in a code freeze, during which
little code gets reviewed or merged. If a reviewer responds with a comment like
R=go1.11 or adds a tag like "wait-release", it means that this CL will be
reviewed as part of the next development cycle. See https://golang.org/s/release
for more details.


Please don’t reply on this GitHub thread. Visit golang.org/cl/374416.
After addressing review feedback, remember to publish your drafts!

@dmitshur
Copy link
Contributor

This PR is currently targeting the "release-branch.go1.17" branch. Go 1.17 is no longer supported per the release policy and so we don't use the release-branch.go1.17 branch for anything now.

If this is a change you'd still like to send, please see https://go.dev/doc/contribute#before_contributing and send it again targeting the branch named master instead. Thanks.

@dmitshur dmitshur closed this May 24, 2023
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 this pull request may close these issues.

3 participants