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
Make data node calls non-blocking and interruptible #5058
Conversation
ec5f276
to
31b8339
Compare
Codecov Report
@@ Coverage Diff @@
## main #5058 +/- ##
==========================================
- Coverage 89.05% 88.84% -0.22%
==========================================
Files 225 225
Lines 51853 52052 +199
==========================================
+ Hits 46180 46246 +66
- Misses 5673 5806 +133
Continue to review full report at Codecov.
|
1a9b13f
to
677e75a
Compare
677e75a
to
845b780
Compare
662d892
to
170aa3b
Compare
170aa3b
to
052f0d4
Compare
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 had one comment. Rest looks good otherwise to me.
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.
Overall looks good, I've left some comments
ResetLatch(MyLatch); | ||
CHECK_FOR_INTERRUPTS(); | ||
} | ||
if (event.events & WL_SOCKET_READABLE) |
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.
Maybe we should check exactly then the read event came from the connection socket here?
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.
There is only the one possibility, but I can assert it.
|
||
do | ||
{ | ||
ret = PQisBusy(conn->pg_conn); |
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.
This part looks good, I was mostly curious about it
@@ -1809,13 +2024,14 @@ remote_connection_drain(TSConnection *conn, TimestampTz endtime, PGresult **resu | |||
/* In what follows, do not leak any PGresults on an error. */ | |||
PG_TRY(); | |||
{ | |||
ModifyWaitEvent(conn->wes, conn->sockeventpos, WL_SOCKET_READABLE, NULL); |
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.
Why do you need this? all the data could be in the buffer already
7f1ad87
to
37d6056
Compare
fb156c6
to
b6e0802
Compare
Broken code caused the async connection module to never send queries using prepared statements. Instead, queries were sent using the parameterized query statement instead. Fix this so that prepared statements are used when created.
Refactor the use of libpq calls to data nodes so that they honor PostgreSQL interrupt handling (e.g., ctrl-c or `statement_timeout`) and don't block unnecessarily. To implement this behavior, data node connections are made non-blocking by default and all `libpq` functions are wrapped to integrate with PostgreSQL's signal handling (via `WaitEventSets`) when waiting for read or write readiness. A change is also made to the life-cycle management of `libpq` objects, including connections, and remote query results. Instead of tying these to transactions, they are now tied to the life-cycle of memory contexts using a callback. In most cases, the memory context a connection is allocated on has the same lifetime as transactions, but not always. For example, the connection cache lives across connections and is using a longer lived memory context. Previously that was handled as a special case where connections were marked to not auto close on transaction end. Closes timescale#4958 Closes timescale#2757
b6e0802
to
7f4a128
Compare
839271e
to
4a56906
Compare
Splitting this up into smaller PRs. |
Refactor the use of libpq calls to data nodes so that they honor PostgreSQL interrupt handling (e.g., ctrl-c or
statement_timeout
) and don't block unnecessarily.To implement this behavior, data node connections are made non-blocking by default and all
libpq
functions are wrapped to integrate with PostgreSQL's signal handling (viaWaitEventSets
) when waiting for read or write readiness.A change is also made to the life-cycle management of
libpq
objects, including connections, and remote query results. Instead of tying these to transactions, they are now tied to the life-cycle of memory contexts using a callback. In most cases, the memory context a connection is allocated on has the same lifetime as transactions, but not always. For example, the connection cache lives across connections and is using a longer lived memory context. Previously that was handled as a special case where connections were marked to not auto close on transaction end.Closes #4958
Closes #2757