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

made to pass connection instead of copying store #801

Merged
merged 2 commits into from Dec 16, 2022

Conversation

sio4
Copy link
Member

@sio4 sio4 commented Dec 11, 2022

What is being done in this PR?

Sample Logs, when a TX is used:

[POP] 2022/12/16 23:44:16 sql - BEGIN Transaction --- (conn=tx-5581905573995530030, tx=5581905573995530030)
[POP] 2022/12/16 23:44:16 sql - INSERT INTO "users" ("created_at", "id", "name", "updated_at") VALUES (:created_at, :id, :name, :updated_at) | [{"id":"a1b61ca5-ba24-4ba4-b111-43e1d39e6bd0","name":"Username","created_at":"2022-12-16T23:44:16.653325+09:00","updated_at":"2022-12-16T23:44:16.653325+09:00"}] (conn=tx-5581905573995530030, tx=5581905573995530030)
[POP] 2022/12/16 23:44:16 sql - END Transaction --- (conn=tx-5581905573995530030, tx=5581905573995530030)

[POP] 2022/12/16 23:44:09 sql - BEGIN Transaction --- (conn=tx-1750268002579520625, tx=1750268002579520625)
[POP] 2022/12/16 23:44:09 sql - SELECT users.created_at, users.id, users.name, users.updated_at FROM users AS users (conn=tx-1750268002579520625, tx=1750268002579520625)
[POP] 2022/12/16 23:44:09 sql - END Transaction --- (conn=tx-1750268002579520625, tx=1750268002579520625)

Sample Logs, when DB pool is used directly while the TX middleware is used:

[POP] 2022/12/16 23:40:50 sql - BEGIN Transaction --- (conn=tx-5119710909779336636, tx=5119710909779336636)
[POP] 2022/12/16 23:40:50 sql - INSERT INTO "users" ("created_at", "id", "name", "updated_at") VALUES (:created_at, :id, :name, :updated_at) | [{"id":"859965da-442a-4f9c-92ef-815d9c260329","name":"Username","created_at":"2022-12-16T23:40:50.389328+09:00","updated_at":"2022-12-16T23:40:50.389328+09:00"}] (conn=conn-4630690138082725292, tx=0, maxconn: 3, openconn: 2, in-use: 1, idle: 1)
[POP] 2022/12/16 23:40:50 sql - END Transaction --- (conn=tx-5119710909779336636, tx=5119710909779336636)

[POP] 2022/12/16 23:41:21 sql - BEGIN Transaction --- (conn=tx-3170621132153068770, tx=3170621132153068770)
[POP] 2022/12/16 23:41:21 sql - SELECT users.created_at, users.id, users.name, users.updated_at FROM users AS users (conn=conn-4630690138082725292, tx=0, maxconn: 3, openconn: 2, in-use: 1, idle: 1)
[POP] 2022/12/16 23:41:21 sql - END Transaction --- (conn=tx-3170621132153068770, tx=3170621132153068770)

What are the main choices made to get to this solution?

  • To make logging/(internal)API simple and consistent with others
  • (minor) reduce variable copying

List the manual test cases you've covered before sending this PR:

  • standard tests
  • a quick and simple stress test with an extremely simple application

fixes #800

@sio4 sio4 self-assigned this Dec 11, 2022
@sio4 sio4 added the enhancement New feature or request label Dec 11, 2022
@sio4 sio4 added this to the v6.1.1 milestone Dec 11, 2022
@sio4 sio4 marked this pull request as draft December 11, 2022 16:40
@sio4 sio4 added the bug Something isn't working label Dec 16, 2022
@sio4 sio4 requested review from a team December 16, 2022 13:41
@sio4 sio4 marked this pull request as ready for review December 16, 2022 13:41
Copy link
Member

@paganotoni paganotoni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. thanks.

@sio4 sio4 merged commit 5dfc37d into main Dec 16, 2022
@sio4 sio4 deleted the pass-connection-instead-of-store branch December 16, 2022 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: DB connection locks up under load calling DB.Create(), regression in 6.1.0 vs 6.0.8
2 participants