Skip to content

fix: correct type mismatches in DLQ process_failed_jobs#3

Merged
ceejbot merged 2 commits into
latestfrom
fix/dlq-type-mismatches
Nov 19, 2025
Merged

fix: correct type mismatches in DLQ process_failed_jobs#3
ceejbot merged 2 commits into
latestfrom
fix/dlq-type-mismatches

Conversation

@rrogers-machinify
Copy link
Copy Markdown
Collaborator

@rrogers-machinify rrogers-machinify commented Nov 19, 2025

Fixes two type mismatches when reading from graphile_worker's jobs table:

  1. priority: Changed from i32 to i16 to match graphile_worker's smallint type
  2. last_error: Changed from Option<serde_json::Value> to Option<String> to match graphile_worker's TEXT type, with conversion to JSONB for DLQ insert

Problem

These mismatches caused the worker to crash with ColumnDecode errors when attempting to move failed jobs to the DLQ:

  • priority: Rust type 'i32' is not compatible with SQL type 'INT2'
  • last_error: Rust type 'Option<serde_json::Value>' is not compatible with SQL type 'TEXT'

Root Cause

The graphile_worker library uses smallint (INT2/i16) for priority and TEXT for last_error, while the backfill_dlq table expects INTEGER and JSONB respectively.

Solution

This fix reads the correct types from the source table and converts last_error from TEXT to JSONB before inserting into DLQ.

Additional Fixes

To make CI pass, this PR also includes fixes for pre-existing issues:

  • Fixed clippy warning: derive Default for Queue enum instead of manual implementation
  • Fixed doctest failures: added missing Serialize/Deserialize derives and explicit type annotations

Testing

All DLQ tests pass (18/18):

  • test_dlq_process_failed_jobs_empty
  • test_dlq_process_failed_jobs_with_mock_data
  • And 16 other DLQ-related tests

Fixes two type mismatches when reading from graphile_worker's jobs table:

1. priority: Changed from i32 to i16 to match graphile_worker's smallint type
2. last_error: Changed from Option<serde_json::Value> to Option<String> to
   match graphile_worker's TEXT type, with conversion to JSONB for DLQ insert

These mismatches caused the worker to crash with ColumnDecode errors when
attempting to move failed jobs to the DLQ:
- priority: 'Rust type `i32` is not compatible with SQL type `INT2`'
- last_error: 'Rust type `Option<serde_json::Value>` is not compatible with SQL type `TEXT`'

The graphile_worker library uses smallint (INT2/i16) for priority and TEXT
for last_error, while the backfill_dlq table expects INTEGER and JSONB
respectively. This fix reads the correct types from the source and converts
last_error from TEXT to JSONB before inserting into DLQ.
Apply clippy suggestion to use derive macro instead of manual implementation.
@ceejbot ceejbot merged commit 6fc5fa8 into latest Nov 19, 2025
1 check passed
@ceejbot ceejbot deleted the fix/dlq-type-mismatches branch November 19, 2025 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants