Compze.DbPool.Service
0.2.5-alpha
Prefix Reserved
See the version list below for details.
dotnet tool install --global Compze.DbPool.Service --version 0.2.5-alpha
dotnet new tool-manifest
dotnet tool install --local Compze.DbPool.Service --version 0.2.5-alpha
#tool dotnet:?package=Compze.DbPool.Service&version=0.2.5-alpha&prerelease
nuke :add-package Compze.DbPool.Service --version 0.2.5-alpha
Compze.DbPool.Service
The DbPool service: one process on a trusted network that owns a PostgreSQL, a MySQL and a SQL Server instance, and lends their empty databases to the tests of every machine there, through Compze.DbPool's providers.
- One service per instance: the service holds a lock on each instance, on a connection of its own, so a second service refuses to start, on whatever address it reaches the instance, and names the machine and process of the one that owns it. A service killed a moment ago holds its lock until its server notices, so a service that starts waits up to 10 seconds for the lock before it refuses.
- Reservations in memory: a restarted service knows nothing of the reservations made before. It empties each database of its pool that it finds and lends it again, even one a test still holds: restart it when no tests run.
- Ready databases: a returned database is emptied in the background, so the next test is lent one already empty.
- Reservations end: a database whose reservation ends before its pool returns it is never lent again, and is dropped once nothing is connected to it.
Running it
dotnet tool install --global Compze.DbPool.Service --prerelease
compze-dbpool-service run
The first run writes a configuration file to fill in, %ProgramData%\Compze.DbPool.Service\configuration.json: the address
of the machine the tests connect to, the port of the service's registry server, and the master connection string of each SQL
instance. A change takes a restart. run --configuration <file> reads another file. A property the file doesn't know is
refused, rather than ignored: PoolName, which version 0.1.0 read, too.
As a Windows service that starts with Windows: compze-dbpool-service install-windows-service [--configuration <file>],
in an elevated prompt, with the configuration filled in. It registers the service, which reads that file each time it
starts, and starts it; its log goes to service.log beside the configuration file. uninstall-windows-service stops it and
removes the registration.
Each master connection string's login must be allowed to create and drop databases. The tests connect with it too, so its host must be a name they can reach.
A PostgreSQL server on Windows wants lc_messages = 'C': otherwise each new connection's backend walks every Windows
locale to resolve the locale's name, which took about a third of PostgreSQL's processor time in Compze's specifications. It
changes only the language of the server's messages, and needs no restart:
ALTER SYSTEM SET lc_messages = 'C';
SELECT pg_reload_conf();
On each machine whose tests use it, set COMPOSABLE_DBPOOL_SERVICE to the service's machine and port, such as
threadripper:7531. A test on the service's own machine finds it at port 7531 without it.
The service authenticates nobody and encrypts nothing, and its answers carry the SQL connection strings, credentials included. Run it only on a network where that is acceptable.
Running it as a child process of your own
A test run that starts its own SQL server can start its own DbPool service over it the same way, with nothing installed on the machine and no fixed port:
Get the tool without installing it for the machine: a local tool manifest in your repository (
dotnet new tool-manifest, thendotnet tool install Compze.DbPool.Service --prerelease, anddotnet tool restorewhere it runs), ordotnet tool install Compze.DbPool.Service --prerelease --tool-path <folder>.Write its configuration to a file of your own:
{ "ListenOn": "127.0.0.1", "RegistryServerPort": 0, "PostgreSql": "Host=localhost;Port=5433;Database=postgres;Username=postgres;Password=...;" }Port 0 has the operating system pick a free port, so two runs side by side don't collide. A loopback
ListenOnkeeps the service to this machine: its registry server then listens on that address alone. Name only the engines you have, and only servers no other DbPool service owns: a second service on a server refuses to start.Start it with its standard input redirected, and keep that open for as long as the service should run:
dotnet tool run compze-dbpool-service run --configuration <file> --address-file <file> --stop-when-stdin-closes(
<folder>/compze-dbpool-service run …for a tool path install.) Name an address file that doesn't exist yet.Start it with the runtime's default socket completions. A parent that sets
DOTNET_SYSTEM_NET_SOCKETS_INLINE_COMPLETIONSremoves it from the child's environment, asstartInfo.Environment.Remove("DOTNET_SYSTEM_NET_SOCKETS_INLINE_COMPLETIONS")does: with it, MySqlConnector deadlocks the service as it stops while a MySQL statement is under way.Wait for the address file. Once the service runs, it writes the address there whole, such as
127.0.0.1:52817, and deletes the file as it stops. If the process exits first, what it wrote to its standard output and error tells why.Set
COMPOSABLE_DBPOOL_SERVICEto that address in the environment of the test processes. Nothing else on the client side changes.Close its standard input to stop it. It stops and exits with 0. Your process ending closes the input too, so a service never outlives the run that started it. Killing it, its process tree under
dotnet tool run, loses nothing either: the reservations were in its memory alone, the SQL server ends its lock with its connection, and the next service resets the databases it finds. It leaves its address file then.
Read its standard output and error as it runs, or send them to a file: it logs there, and a pipe nobody reads stalls it once full.
License
Apache-2.0
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
This package has no dependencies.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.19.0-alpha | 0 | 12/5/2026 |
| 0.18.1-alpha | 0 | 12/5/2026 |
| 0.18.0-alpha | 0 | 12/5/2026 |
| 0.17.1-alpha | 0 | 12/5/2026 |
| 0.17.0-alpha | 0 | 12/5/2026 |
| 0.16.0-alpha | 0 | 12/5/2026 |
| 0.15.1-alpha | 0 | 12/5/2026 |
| 0.15.0-alpha | 0 | 12/5/2026 |
| 0.14.0-alpha | 0 | 12/5/2026 |
| 0.5.2-alpha | 7 | 12/5/2026 |
| 0.5.1-alpha | 31 | 12/5/2026 |
| 0.5.0-alpha | 77 | 12/5/2026 |
| 0.4.0-alpha | 65 | 12/5/2026 |
| 0.3.5-alpha | 54 | 12/5/2026 |
| 0.3.4-alpha | 60 | 12/4/2026 |
| 0.3.3-alpha | 52 | 12/4/2026 |
| 0.3.2-alpha | 71 | 12/4/2026 |
| 0.3.1-alpha | 84 | 12/4/2026 |
| 0.3.0-alpha | 49 | 12/4/2026 |
| 0.2.5-alpha | 52 | 12/4/2026 |
- The tool includes Compze.DbPool.ServiceClient 0.2.3-alpha, Compze.Hosting 0.10.4-alpha and Compze.Tessaging 0.25.1-alpha. The bundled Tessaging patch keeps a retiring delivery stream from losing a disconnected subscriber's queued tevent.