-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
fix(db) postgres connector keepalive errors on load #3423
Conversation
b511d92
to
c7f366b
Compare
@@ -158,71 +142,76 @@ function _mt:setkeepalive() | |||
end | |||
|
|||
if not ok then | |||
log(WARN, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if pre-existing prior to this PR, such logging message really should have some context prepended to them for users to understand their meaning.
|
||
if connection then | ||
return connection:query(sql) | ||
local function query(sql, self) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not following the self
as a first argument convention - maybe we should?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also notice we made this function a local, but the only place it is being called is in _mt:query()
- it seems like unnecessary abstraction?
if connection then | ||
return connection:query(sql) | ||
local function query(sql, self) | ||
if self.connection and self.connection.sock then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't the fix be more concise if it simply added checks for self.connection.sock
in the places you just added it? I'm not quite sure making setkeepalive()
and connect()
local functions really helps? It seems like it just makes the logic more difficult to follow: we sometimes call setkeepalive()
, and some other times call self:setkeepalive()
- the latter just unsetting self.connection
, but that seems unnecessary since the former will already unset self.connection.sock
, and we now check for this value in query()
?)
76db0be
to
d991cb9
Compare
d991cb9
to
4d4e049
Compare
I still struggle to see the difference before and after the patch, a lot of it seems to be re-factoring. What is the part that fixes it exactly, and what was the root cause for the bug? The PR description is very vague on details. |
The biggest change is that when you don't have |
But I agree, if user ever calls |
Gotcha. The Let's merge this for now, and consider what to do with |
Summary
Postgres strategy (new model) could result error like the below when running multiple subsequent Admin API calls rapidly (or parallel):