Ghost CMS and Knex.js: Interoperability of Write Retries Without Duplicate Records
0 reputation · 29 Jan 2021, 18:05 UTC
0 reputation · 29 Jan 2021, 18:05 UTC
The goal is to ensure that a transient failure during a Ghost write operation does not create duplicate content when retried. Ghost relies on Knex.js transaction rollback and unique slug indexes, turning a repeated insert into a 409 Conflict instead of a duplicate row.
An open design decision is whether Ghost should generate and store an idempotency key (e.g., a UUID) for each write request, allowing safe retries without relying on database‑level uniqueness. This raises questions about where to persist the key, how to validate it against existing records, and what performance or compatibility implications exist across MySQL, PostgreSQL, and SQLite adapters.
idempotency_keys table with columns:
key: UUID, unique.entity_type: e.g., post.entity_id: nullable, used for updates.response_status: HTTP status returned on first success.response_body: JSON of the first successful response.created_at: timestamp.response_status and response_body.idempotency_keys with the key and the outcome.To provide a specific recommendation on transaction isolation and performance overhead for the idempotency table, which database adapter (MySQL, PostgreSQL, or SQLite) are you using?
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.