Commit 0c674ef
committed
build: bump pgwire to 0.39 and migrate to SessionExtensions
pgwire 0.39.0 added typed per-connection state via `SessionExtensions`,
which was the upstream change `TODO.md` was waiting for. Migrate
`ConnectionState` storage off the global `DashMap` keyed by
`{addr}_{pid}` and onto `client.session_extensions()`.
Mechanical changes:
- `session.rs`: drop the `CONNECTIONS` global, the `_conn_id`
metadata key, `register_connection`, `get_connection`, and
`remove_connections_for_addr`. Cancel registry stays — a
`CancelRequest` arrives on a *different* TCP connection that
doesn't have access to the originating connection's
`SessionExtensions`, so a process-wide map is still required.
Replaced its `dashmap::DashMap` with `Mutex<HashMap>` since the
registry is small and only touched on connect/disconnect/cancel.
- `cancel.rs`: `lookup_cancel` now returns the cloned `(client,
active_query_id)` pair directly, so the registry mutex is
released before any await and the previous "snapshot then drop
the ref guard" dance is gone.
- `startup.rs::establish_session`: replaces `register_connection`
with `client.session_extensions().insert(ConnectionState { ... })`.
No more `_conn_id` formatting or metadata insertion.
- `query_simple.rs` / `query_extended.rs`: replace
`session::get_connection(&conn_id)` with
`client.session_extensions().get::<ConnectionState>()`. The
returned `Arc<ConnectionState>` is `Send + Sync + 'static`, so we
drop the per-handler `Arc::clone` dance and the
`drop(conn_state)` before-await workaround.
- `main.rs`: drop `ConnectionCleanup` (the per-task drop guard that
called `remove_connections_for_addr`). Cleanup happens via
`Drop for ConnectionState` when pgwire tears down the connection's
`SessionExtensions`.
- `Cargo.toml`: drop `dashmap` direct dependency (still pulled in
transitively by trino-rust-client).
- `SimpleQueryHandler` no longer requires `ClientPortalStore` in
0.39 — drop the trait bound.
Also bumps tokio (1.52.0 -> 1.52.1) and rustls-pki-types (1.14.0 ->
1.14.1) to their latest patch revisions.
`cargo build --all-targets`, `cargo test --lib` (191 passed),
`cargo test --bin` (5 passed), `cargo clippy --all-targets -- -D
warnings`, `cargo fmt --check`, and `reuse lint` (59/59) all pass
post-migration.
Net: -125 lines (244 deletions, 119 insertions).1 parent cece3ed commit 0c674ef
8 files changed
Lines changed: 119 additions & 244 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | 24 | | |
26 | 25 | | |
27 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
38 | 37 | | |
39 | 38 | | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
45 | 42 | | |
46 | 43 | | |
47 | 44 | | |
48 | | - | |
49 | 45 | | |
50 | 46 | | |
51 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | 3 | | |
5 | 4 | | |
6 | 5 | | |
| |||
15 | 14 | | |
16 | 15 | | |
17 | 16 | | |
18 | | - | |
19 | 17 | | |
20 | 18 | | |
21 | 19 | | |
| |||
31 | 29 | | |
32 | 30 | | |
33 | 31 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | 32 | | |
45 | 33 | | |
46 | 34 | | |
| |||
153 | 141 | | |
154 | 142 | | |
155 | 143 | | |
156 | | - | |
157 | 144 | | |
158 | | - | |
| 145 | + | |
159 | 146 | | |
160 | 147 | | |
161 | 148 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| 89 | + | |
89 | 90 | | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
98 | 94 | | |
99 | 95 | | |
100 | 96 | | |
| |||
104 | 100 | | |
105 | 101 | | |
106 | 102 | | |
107 | | - | |
| 103 | + | |
108 | 104 | | |
109 | 105 | | |
110 | 106 | | |
111 | | - | |
112 | 107 | | |
113 | 108 | | |
114 | 109 | | |
115 | 110 | | |
116 | 111 | | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
124 | 119 | | |
125 | 120 | | |
126 | 121 | | |
127 | 122 | | |
128 | 123 | | |
129 | 124 | | |
130 | 125 | | |
131 | | - | |
132 | 126 | | |
133 | 127 | | |
134 | 128 | | |
135 | 129 | | |
136 | 130 | | |
137 | 131 | | |
138 | 132 | | |
139 | | - | |
140 | 133 | | |
141 | 134 | | |
142 | 135 | | |
| |||
185 | 178 | | |
186 | 179 | | |
187 | 180 | | |
| 181 | + | |
188 | 182 | | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
196 | 186 | | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | 187 | | |
205 | | - | |
206 | | - | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
207 | 195 | | |
208 | 196 | | |
209 | 197 | | |
| |||
228 | 216 | | |
229 | 217 | | |
230 | 218 | | |
231 | | - | |
| 219 | + | |
232 | 220 | | |
233 | 221 | | |
234 | 222 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | 4 | | |
6 | 5 | | |
7 | 6 | | |
| 7 | + | |
| 8 | + | |
8 | 9 | | |
9 | | - | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | | - | |
15 | 13 | | |
16 | | - | |
| 14 | + | |
17 | 15 | | |
18 | 16 | | |
19 | 17 | | |
| |||
22 | 20 | | |
23 | 21 | | |
24 | 22 | | |
25 | | - | |
| 23 | + | |
26 | 24 | | |
27 | 25 | | |
28 | 26 | | |
29 | 27 | | |
30 | 28 | | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
37 | 32 | | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | 33 | | |
48 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
49 | 41 | | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
56 | 46 | | |
57 | 47 | | |
58 | 48 | | |
| |||
0 commit comments