#6654·lemmy

[Bug]: Malformed SQL Query - Invalid 'rrq' Prefix in SELECT Statement

Author: TealkCreated Aug 25, 2026Updated Sep 9, 2026
Labelsbug

Requirements

  • Is this a bug report? For questions or discussions use https://lemmy.ml/c/lemmy_support or the matrix chat.
  • Did you check to see if this issue already exists?
  • Is this only a single bug? Do not put multiple bugs in one issue.
  • Do you agree to follow the rules in our Code of Conduct?
  • Is this a backend issue? Use the lemmy-ui repo for UI / frontend issues.

Summary

PostgreSQL is rejecting a malformed SQL query with an invalid "rrq" prefix prepended to SELECT statements. The query rrqSELECT instance_id, last_successful_id FROM federation_queue_state LIMIT 5; fails with a syntax error. This appears to be a query builder or string concatenation bug in the federation queue state handling code.

Steps to Reproduce

  1. Set up a Lemmy instance with federation enabled
  2. Allow the instance to receive and process federated activities
  3. Wait for or trigger federation queue state queries to be executed
  4. Monitor PostgreSQL logs for SQL errors
  5. Observe the malformed query with "rrq" prefix appearing in logs

Technical Details

PostgreSQL Error Log: 2026-08-25 21:06:59.898 GMT [175] ERROR: syntax error at or near "rrqSELECT" at character 1 2026-08-25 21:06:59.898 GMT [175] STATEMENT: rrqSELECT instance_id, last_successful_id FROM federation_queue_state LIMIT 5;

OS: Alpine Linux (x86_64-pc-linux-musl) PostgreSQL Version: 16.14 Compiler: gcc 15.2.0

Version

0.19.20

Lemmy Instance URL

rollenspiel.forum