PgQue icon indicating copy to clipboard operation
PgQue copied to clipboard

fix(upgrade): preserve legacy consumers containing # in 0.3

Open NikolayS opened this issue 4 months ago • 1 comments

Severity

High — v0.2.0 upgrade compatibility / stranded consumers.

Problem

PgQue 0.2.0 allowed ordinary consumer names containing #. The 0.3 development build treats any # name as an internal partition-slot consumer in receive, ack, and nack.

A valid v0.2 consumer and its pending state survive an in-place upgrade, but the modern consume API becomes unusable:

ERROR: consumer team#1 is a partition slot consumer; use pgque.receive_partitioned()

Affected code:

  • devel/sql/pgque-api/receive.sql
  • devel/sql/pgque-api/send.sql

Reproduction

Install v0.2.0:sql/pgque.sql, then:

select pgque.create_queue('q');
select pgque.subscribe('q', 'team#1');
select pgque.send('q', '{}');
select pgque.force_next_tick('q');
select pgque.ticker();

Apply current devel/sql/pgque.sql in one transaction, then:

select * from pgque.receive('q', 'team#1', 10);
-- ERROR: misclassified as a partition slot

A legacy name matching base#k/N can also be silently reused by subscribe_slot because engine registration is idempotent.

Expected fix

Detect an actual partition slot from catalog state (partition_consumer / partition_slot plus queue and generated slot identity), not from string presence alone. It is fine to keep rejecting new ordinary # consumers, but existing v0.2 consumers must continue through receive/ack/nack.

Add a committed v0.2.0→HEAD upgrade fixture on oldest/newest supported PostgreSQL with a pending team#1 event and post-upgrade receive/ack assertions.

NikolayS avatar Jul 10 '26 09:07 NikolayS

Shipped in v0.3.0-rc.2 (merged to main via #395 at f4c7457): https://github.com/NikolayS/PgQue/releases/tag/v0.3.0-rc.2

NikolayS avatar Nov 21 '26 16:11 NikolayS