Skip to content

Commit af1716b

Browse files
authored
Flush stats (#38)
* flush stats * stats * refactor
1 parent 3f16123 commit af1716b

File tree

3 files changed

+125
-106
lines changed

3 files changed

+125
-106
lines changed

README.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ Meow. PgBouncer rewritten in Rust, with sharding, load balancing and failover su
1111
## Features
1212
| **Feature** | **Status** | **Comments** |
1313
|--------------------------------|-----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------|
14-
| Transaction pooling | :heavy_check_mark: | Identical to PgBouncer. |
15-
| Session pooling | :heavy_check_mark: | Identical to PgBouncer. |
16-
| `COPY` support | :heavy_check_mark: | Both `COPY TO` and `COPY FROM` are supported. |
17-
| Query cancellation | :heavy_check_mark: | Supported both in transaction and session pooling modes. |
18-
| Load balancing of read queries | :heavy_check_mark: | Using round-robin between replicas. Primary is included when `primary_reads_enabled` is enabled (default). |
19-
| Sharding | :heavy_check_mark: | Transactions are sharded using `SET SHARD TO` and `SET SHARDING KEY TO` syntax extensions; see examples below. |
20-
| Failover | :heavy_check_mark: | Replicas are tested with a health check. If a health check fails, remaining replicas are attempted; see below for algorithm description and examples. |
21-
| Statistics reporting | :heavy_check_mark: | Statistics similar to PgBouncers are reported via StatsD. |
14+
| Transaction pooling | :white_check_mark: | Identical to PgBouncer. |
15+
| Session pooling | :white_check_mark: | Identical to PgBouncer. |
16+
| `COPY` support | :white_check_mark: | Both `COPY TO` and `COPY FROM` are supported. |
17+
| Query cancellation | :white_check_mark: | Supported both in transaction and session pooling modes. |
18+
| Load balancing of read queries | :white_check_mark: | Using round-robin between replicas. Primary is included when `primary_reads_enabled` is enabled (default). |
19+
| Sharding | :white_check_mark: | Transactions are sharded using `SET SHARD TO` and `SET SHARDING KEY TO` syntax extensions; see examples below. |
20+
| Failover | :white_check_mark: | Replicas are tested with a health check. If a health check fails, remaining replicas are attempted; see below for algorithm description and examples. |
21+
| Statistics reporting | :white_check_mark: | Statistics similar to PgBouncers are reported via StatsD. |
2222
| Live configuration reloading | :construction_worker: | Reload config with a `SIGHUP` to the process, e.g. `kill -s SIGHUP $(pgrep pgcat)`. Not all settings can be reloaded without a restart. |
2323
| Client authentication | :x: :wrench: | On the roadmap; currently all clients are allowed to connect and one user is used to connect to Postgres. |
2424

@@ -75,15 +75,15 @@ See [sharding README](./tests/sharding/README.md) for sharding logic testing.
7575

7676
| **Feature** | **Tested in CI** | **Tested manually** | **Comments** |
7777
|-----------------------|--------------------|---------------------|--------------------------------------------------------------------------------------------------------------------------|
78-
| Transaction pooling | :heavy_check_mark: | :heavy_check_mark: | Used by default for all tests. |
79-
| Session pooling | :heavy_check_mark: | :heavy_check_mark: | Tested by running pgbench with `--protocol prepared` which only works in session mode. |
80-
| `COPY` | :heavy_check_mark: | :heavy_check_mark: | `pgbench -i` uses `COPY`. `COPY FROM` is tested as well. |
81-
| Query cancellation | :heavy_check_mark: | :heavy_check_mark: | `psql -c 'SELECT pg_sleep(1000);'` and press `Ctrl-C`. |
82-
| Load balancing | :x: | :heavy_check_mark: | We could test this by emitting statistics for each replica and compare them. |
83-
| Failover | :x: | :heavy_check_mark: | Misconfigure a replica in `pgcat.toml` and watch it forward queries to spares. CI testing could include using Toxiproxy. |
84-
| Sharding | :heavy_check_mark: | :heavy_check_mark: | See `tests/sharding` and `tests/ruby` for an Rails/ActiveRecord example. |
85-
| Statistics reporting | :x: | :heavy_check_mark: | Run `nc -l -u 8125` and watch the stats come in every 15 seconds. |
86-
| Live config reloading | :heavy_check_mark: | :heavy_check_mark: | Run `kill -s SIGHUP $(pgrep pgcat)` and watch the config reload. |
78+
| Transaction pooling | :white_check_mark: | :white_check_mark: | Used by default for all tests. |
79+
| Session pooling | :white_check_mark: | :white_check_mark: | Tested by running pgbench with `--protocol prepared` which only works in session mode. |
80+
| `COPY` | :white_check_mark: | :white_check_mark: | `pgbench -i` uses `COPY`. `COPY FROM` is tested as well. |
81+
| Query cancellation | :white_check_mark: | :white_check_mark: | `psql -c 'SELECT pg_sleep(1000);'` and press `Ctrl-C`. |
82+
| Load balancing | :x: | :white_check_mark: | We could test this by emitting statistics for each replica and compare them. |
83+
| Failover | :x: | :white_check_mark: | Misconfigure a replica in `pgcat.toml` and watch it forward queries to spares. CI testing could include using Toxiproxy. |
84+
| Sharding | :white_check_mark: | :white_check_mark: | See `tests/sharding` and `tests/ruby` for an Rails/ActiveRecord example. |
85+
| Statistics reporting | :x: | :white_check_mark: | Run `nc -l -u 8125` and watch the stats come in every 15 seconds. |
86+
| Live config reloading | :white_check_mark: | :white_check_mark: | Run `kill -s SIGHUP $(pgrep pgcat)` and watch the config reload. |
8787

8888
## Usage
8989

src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ async fn main() {
111111

112112
// Collect statistics and send them to StatsD
113113
let (tx, rx) = mpsc::channel(100);
114-
114+
let collector_tx = tx.clone();
115115
tokio::task::spawn(async move {
116-
let mut stats_collector = Collector::new(rx);
116+
let mut stats_collector = Collector::new(rx, collector_tx);
117117
stats_collector.collect().await;
118118
});
119119

0 commit comments

Comments
 (0)