Commit Graph

52 Commits (14eedb4fcaa7eec18725aeb692346a1d2e883b30)

Author SHA1 Message Date
Jack Christensen 14eedb4fca Add ConnPool context methods 2017-02-06 18:54:49 -06:00
Jack Christensen d398d95764 Explicitly close checked-in connections on ConnPool.Reset 2017-01-23 22:48:17 -06:00
Alexander Staubo f1de186a93 Connection pool timeout should return a consistent error value so clients can test for it. 2016-10-03 15:56:01 -04:00
Martin Hamrle 9f6b99e332 Cleanups
Cleanups suggested by gometalinter tools.
2016-08-30 20:05:44 +02:00
Jack Christensen 5f7d01778e Add CopyTo to support PostgreSQL copy protocol
fixes #102
2016-08-10 16:27:44 -05:00
Jack Christensen 7e43eca3d3 Remove one allocation per pool query 2016-08-08 16:31:01 -05:00
Jack Christensen ecf158b086 Track and check number of in-progress acquires 2016-07-15 14:46:50 -05:00
konstantin b96777edf3 Merge branch 'Non_blocking_ConnPool_Acquire' into tmp
Conflicts:
	conn_pool.go
2016-07-06 16:58:04 +03:00
konstantin 809be4bfcb Make ConnPool.Acquire() non blocking, feedback 2016-07-06 16:22:59 +03:00
konstantin 7f9373c7c0 Make ConnPool.Acquire() non blocking
When there was an issue with DB server ConnPool.Acquire() used to block
until it heard back from the server or its OpenTimeout hit. If we had
OpenTimeout set to 3 secs, and there were X go routines trying to aquire a
connection in parallel, the very last go routine would receive timeout
error in X*OpenTimeout seconds because of the blocking nature of the
ConnPool.Acquire().

With this commit ConnPool.Acquire() is not blocking any more, and all
X requests will take about 1*OpenTimeout secs to fail.
2016-07-05 18:04:41 +03:00
Jack Christensen 40f00f4a82 Pass PrepareEx opts as pointer and DRY implementation 2016-05-20 08:30:10 -05:00
Jack Christensen b06560aa03 Rename Preparex to PrepareEx 2016-05-20 08:14:56 -05:00
William King 2ba5bb405b Slight doc update 2016-05-18 13:27:22 -07:00
William King e417cc2f15 Preparex 2016-05-18 13:15:15 -07:00
John Barker a282d9df90 Cache connection properties in the pool
This is a quick attempt to improve connection startup time by caching
the properties that are loaded when a connection is ready in the pool,
so that further connections don't incur this cost.

I'm not entirely convinced by the interface here, perhaps these 3 items
could live in their own type and that be passed around for clearer code,
but the idea works well.
2016-05-10 18:34:26 -04:00
Jack Christensen acd9c01bd6 Fix ConnPool.Deallocate 2016-04-30 12:22:26 -05:00
konstantin d4258bb47f Add AcquireTimeout support 2016-04-11 13:35:16 -07:00
Jack Christensen 04e9fbcc55 Fix some golint errors
- Add comments
- Rename variables
- Remove unnecessary "else"
2016-03-29 15:18:09 -05:00
Jack Christensen 1ad4c0090a Add ConnPool Prepare and Deallocate
fixes #68
2016-03-04 16:26:27 -06:00
Jack Christensen 20d22a67e3 Prevent deadlock on ConnPool.Acquire with Reset
If no connections are available, and the pool is reset, there will
be no connections at all in the pool. So the pool needs to be able
to create a connection after waiting for a connection to be released.
2016-03-04 16:19:48 -06:00
Jack Christensen a93025479d Add AfterClose and Conn to Rows 2016-02-13 13:03:06 -06:00
Jack Christensen e8dcf5b3ac Add *Tx.AfterClose hook
ConnPool now implements its connection with Tx via this hook instead of
manipulating the internals of Tx.
2016-02-13 11:06:44 -06:00
Jack Christensen f004f0802c Add ConnPool.Reset method
refs #110
2015-12-12 13:15:14 -06:00
Jack Christensen 20cf4f87ab Remove notifications when releasing Conn to Pool 2015-09-26 13:24:21 -05:00
Jack Christensen ca16a4c98f Unlisten tweaks
- Use unlisten * when releasing connection with listeners to pool
- Only unlisten on releasing connection to pool when necessary
- Remove Unlisten("") as was to release all listeners
2015-09-21 08:18:10 -05:00
Joseph Glanville eb5cadccf9 Track Listen/Unlisten and clear subscriptions on conn release 2015-09-21 07:56:45 -05:00
Jack Christensen a1aa06c934 More efficient logging with log levels 2015-09-16 08:20:51 -05:00
Jack Christensen 93aa2b2e80 ConnPool.Begin retry logic checks connection IsAlive
ErrDeadConn is returned when calling an already dead connection. But the initial failure returns the real error. So we check for IsAlive instead of ErrDeadConn.

Added test for ConnPool.Begin retry logic.
2015-09-12 19:39:37 -05:00
Jack Christensen bc4742b80a DRY ConnPool Begin and BeginIso 2015-09-12 19:12:55 -05:00
Jack Christensen 6ac98ef613 Add test for ConnPool.Begin retry
Also fix bug where conn is not released on non ErrDeadConn error
returned from Conn.Begin
2015-09-12 19:10:55 -05:00
Joseph Glanville 4868929ff1 ConnPool.Begin/BeginIso will retry if they Acquire a dead connection 2015-09-11 03:05:43 +10:00
Jack Christensen db5300358a Allow ConnPool to have MaxConnections of 1 2015-05-25 09:54:56 -05:00
Jack Christensen d2ce556450 ConnPool no longer creates connections just to release them. 2014-11-12 08:11:33 -06:00
Jack Christensen efea92e8be Fix connection pool close
Close should close successfully acquired connections, not failures.

fixes #45
2014-11-11 17:59:13 -06:00
Jack Christensen f5156ac4eb discardLogger should be private 2014-09-04 16:45:35 -05:00
Jack Christensen 98109c57bb Use interface for logging instead of log15 directly 2014-09-04 16:00:53 -05:00
Jack Christensen aff5043df9 Added a lot of documentation 2014-07-12 21:17:38 -05:00
Jack Christensen e33fb9d5d8 Remove ConnPool functions overlapped by Stat 2014-07-12 20:12:56 -05:00
Jack Christensen ae6a87545b Use database/sql style transaction interface 2014-07-12 07:59:30 -05:00
Jack Christensen f31665c5db wip 2014-07-12 07:11:16 -05:00
Jack Christensen d7529600e0 Rename QueryResult to Rows
This helps conform closer to database/sql
2014-07-11 08:21:29 -05:00
Jack Christensen 43dcd47a92 Move to Scan interface
Remove SelectValue
2014-07-05 18:23:19 -05:00
Jack Christensen 5b345e80e1 Remove SelectValueTo
Benchmarks revealed that it is no longer performant enough to pull
its own wait. Using go_db_bench to copy JSON results to HTTP responses
it was ~20% *slower* for ~4BK responses and less than 10% faster for
+1MB responses.

The the performance problem was in io.CopyN / io.Copy. io.Copy
allocates a 32KB buffer if it doesn't have io.WriterTo or io.ReaderFrom
available. This extra alloc on every request was more expensive than
just reading the result into a string and writing it out to the response
body.

Tests indicated that if MsgReader implemented a custom Copy that used a
shared buffer it might have a few percent performance advantage. But the
additional complexity is not worth the performance gain.
2014-07-05 09:32:47 -05:00
Jack Christensen d30ef1b8b9 Replace SelectFunc with Query as core 2014-06-28 17:07:31 -05:00
Jack Christensen b6ac3ef2b0 Rename Execute to Exec 2014-06-27 14:56:27 -05:00
Jack Christensen 6bb0a9fa75 Default ConnPool MaxConnections to 5, require min of 2 2014-06-21 18:21:41 -05:00
Jack Christensen cbddbb423e Replace logging functionality with log15
gopkg.in/inconshreveable/log15.v2
2014-06-02 19:47:09 -05:00
Jack Christensen f119d5221c Add CommandTag 2014-05-19 09:32:31 -05:00
Jack Christensen 6d6fb4561a ConnPoolConfig embeds ConnConfig 2014-05-19 07:59:51 -05:00
Jack Christensen 9067b2d991 Rename ConnectionPoolOptions to ConnPoolConfig 2014-05-17 13:44:55 -05:00