Skip to content

Commit faaa7a5

Browse files
jaredLundeclaude
andcommitted
fix e2e: handle NULL flush_lsn + correct ed25519 cert size threshold
Two bugs in the new tests caught by the previous CI run: 1. slot_blocks_wal_pruning_when_consumer_stops: the SIGSTOP'd sink transiently disappears from pg_stat_replication, so flush_lsn could come back NULL. We were deserialising as bool and panicking with "error retrieving column 0". Switch to Option<bool> + treat NULL as not-yet-caught-up. 2. tls_integration_postgres_with_beyond_pg_cert: the sanity threshold was 1024 bytes, but ed25519 PEM certs are ~470 bytes (small key, small cert). Drop the threshold to 300 bytes — still well above any empty/stub but below real ed25519 cert content. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent e2dfe3f commit faaa7a5

1 file changed

Lines changed: 17 additions & 10 deletions

File tree

beyond-pg-sink/tests/e2e.rs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6504,10 +6504,11 @@ fn tls_integration_postgres_with_beyond_pg_cert() {
65046504
assert!(key_path.exists(), "server.key missing");
65056505

65066506
// Assertion C: cert content is non-trivial. ensure_cert wrote a real PEM,
6507-
// not an empty stub. >1 KB is well above the floor for a real cert.
6507+
// not an empty stub. Ed25519 certs are compact (~470 bytes PEM-encoded);
6508+
// 300 bytes is well above any plausible empty/stub but below real content.
65086509
let cert_size = std::fs::metadata(&cert_path).unwrap().len();
65096510
assert!(
6510-
cert_size > 1024,
6511+
cert_size > 300,
65116512
"ensure_cert produced suspiciously small cert: {cert_size} bytes"
65126513
);
65136514

@@ -7343,17 +7344,21 @@ fn slot_blocks_wal_pruning_when_consumer_stops() {
73437344
.get(0);
73447345
let deadline = Instant::now() + Duration::from_secs(30);
73457346
loop {
7346-
let flushed: Option<bool> = client
7347+
// flush_lsn can transiently be NULL before the standby has fully
7348+
// initialised, so deserialise as Option<bool> and treat NULL as false.
7349+
let row = client
73477350
.query_opt(
73487351
&format!(
73497352
"SELECT flush_lsn >= '{seed_lsn}'::pg_lsn \
73507353
FROM pg_stat_replication WHERE application_name='wal_sink_blocked'"
73517354
),
73527355
&[],
73537356
)
7354-
.unwrap()
7355-
.map(|r| r.get(0));
7356-
if flushed == Some(true) {
7357+
.unwrap();
7358+
let flushed = row
7359+
.and_then(|r| r.try_get::<_, Option<bool>>(0).ok().flatten())
7360+
.unwrap_or(false);
7361+
if flushed {
73577362
break;
73587363
}
73597364
if Instant::now() > deadline {
@@ -7442,17 +7447,19 @@ fn slot_blocks_wal_pruning_when_consumer_stops() {
74427447
.get(0);
74437448
let deadline = Instant::now() + Duration::from_secs(60);
74447449
loop {
7445-
let caught: Option<bool> = client
7450+
let row = client
74467451
.query_opt(
74477452
&format!(
74487453
"SELECT flush_lsn >= '{current_lsn}'::pg_lsn \
74497454
FROM pg_stat_replication WHERE application_name='wal_sink_blocked'"
74507455
),
74517456
&[],
74527457
)
7453-
.unwrap()
7454-
.map(|r| r.get(0));
7455-
if caught == Some(true) {
7458+
.unwrap();
7459+
let caught = row
7460+
.and_then(|r| r.try_get::<_, Option<bool>>(0).ok().flatten())
7461+
.unwrap_or(false);
7462+
if caught {
74567463
break;
74577464
}
74587465
if Instant::now() > deadline {

0 commit comments

Comments
 (0)