Commit Graph

63 Commits

Author SHA1 Message Date
Joris Vink 73055662de Remove start from pgsql_job 2014-09-18 10:49:15 +02:00
Joris Vink 7e74cd6e62 Introduce a wait queue for our pgsql code.
Instead of letting http_requests spin, if we cannot allocate
a connection for the request we will queue them up put them to sleep.

When a connection becomes available, we'll wake up a request that
was waiting for a connection and let it continue.

This completely avoids consuming massive amounts of cpu time
when dealing with thousands of requests waiting for a pgsql
worker to become ready.
2014-08-21 16:36:12 +02:00
Joris Vink 8565b47800 Attach tasks/pgsqls to http_requests once more.
This way if an http request is removed while tasks or
pgsqls are still active they are free'd out and cancelled
properly.
2014-08-14 22:05:34 +02:00
Joris Vink f021c8db44 pgsql improvements
* set pgsql->result to NULL when we freed it
* drain the connection pipe just in case in pgsql_conn_release()
2014-08-14 16:43:40 +02:00
Joris Vink 9ea1e3cb57 Properly release pgsql connection if needed 2014-08-14 14:46:21 +02:00
Joris Vink f93747828c Major pgsql rework.
Gone is the ugly KORE_PGSQL macro that hid an overly complex
state machine for the pgsql api.
Gone is the pgsql array that was attached to http_requests.
Gone are the callback hacks inside the pgsql api.

Instead, I strongly encourage people to use the new state machine
api Kore offers to properly deal with asynchronous queries.

The pgsql example in examples/pgsql has been updated to reflect
these changes.
2014-08-14 14:34:23 +02:00
Joris Vink a5806d91f8 Pull in pg_config.h correctly, fixes compilation for pgsql under OpenBSD 2014-07-18 15:59:07 +02:00
Joris Vink 19d146a09e Introduce http_request_sleep() and http_request_wakeup().
These 2 functions can be used to move an HTTP request
from/to the active http_requests list. Effectively
putting them to "sleep" or "waking them up".

Sprinkle this through the pgsql and task code.

If used correctly greatly reduces overhead for
managing sleeping tasks.
2014-07-04 16:51:19 +02:00
Joris Vink 1ad9f039ab Add pgsql_conn_max configuration parameter.
Allows you to tune how many pgsql connections kore
will make at one time.
2014-07-04 09:14:05 +02:00
Joris Vink 8b20dec081 Add missing pg_config.h header 2014-07-04 09:03:19 +02:00
Joris Vink 8e0ab8cc61 Check for pg version >= 90200 before using PGRES_SINGLE_TUPLE 2014-07-03 22:58:04 +02:00
Joris Vink 2c6b5e6b0f Normalize kore_*.h headers 2014-07-03 22:14:46 +02:00
Joris Vink be4b1c7e7b Move actual code out of contrib into src/. 2014-07-02 12:19:38 +02:00