Skip to content

TMS: stuck bill_export

Rows that have metadata->'processing' set to true either currently actively running or stuck.

SELECT
  index,
  uuid,
  org_uuid,
  xml_bytes,
  metadata->'processing' AS processing,
  created,
  updated,
  deleted_state,
  period_begin,
  period_end,
  banking_completed
-- Finnish time is three hours ahead database timestamps
FROM bill_export WHERE updated > '2025-05-20 05:00:00';
-- WHERE metadata->>'processing = 'true';

Deleting a single row: Since we cannot use LIMIT for the DELETE query, be very very sure that you are only targeting a single row:

BEGIN ;
DELETE FROM bill_export
WHERE index = <row-index> AND org_uuid = '<org_uuid>' AND metadata->>'processing' = 'true';

You should always know how many rows you are expecting to delete. Here we expect one row:

DELETE 1

When you're absolutely certain and preferably confirmed with PM, COMMIT changes:

COMMIT ;