AI Lab: resuming a failed publish without duplicates

On this page

Publishing the same article in Italian, English and Spanish is not a single operation. It is three separate post creations on WordPress, followed by three ledger records and a final step that links the versions together. If the connection drops after the second one, the site is left with a pair instead of a set of three. The real risk comes later, when someone reruns the whole job and the two versions already online get created a second time.

Why a blind retry creates duplicates

WordPress does not refuse a second post with the same address. The wp_unique_post_slug function makes the slug unique by adding a numeric suffix, so the duplicate appears without any error, at an address almost identical to the original. Anyone who only looks at the command’s exit status sees a success.

The problem is familiar to anyone who works with APIs. Stripe’s documentation on idempotent requests describes it well: after a connection error you need a way to repeat the request without performing the same operation twice. WordPress offers no key of that kind for creating a post, so the protection has to be built around it.

The checks, in order

  • Before starting, check-group reads the publication ledger and reports which of the three languages are already recorded and which are missing. It reserves nothing and writes nothing.
  • Right before each individual publication, check-new refuses a rubric slug that is already in the ledger.
  • The publishing script takes an exclusive lock with flock: if another publication is running it waits up to two minutes, then gives up.
  • Before creating the post it compares title and slug with the latest 500 posts on the site, drafts and scheduled posts included, and also recognizes a slug carrying the WordPress numeric suffix. For translations it also checks that the Italian original does not already have a version in that language.
  • After each language, the post ID is saved in a local manifest and the publication is recorded immediately, without waiting for the other two.
  • The final linking step keeps members that are already verified and stops if it finds a conflicting group.

Six tests, nothing published

On 15 November 2026 I ran the two preliminary checks by hand, read-only, using the slugs of last Sunday’s trilingual issue and a few test slugs that were never published. The hash of the ledger file was identical before and after the tests.

  • Complete set of three: passed, with the message that the group is already recorded and must not be republished, and no missing language.
  • Italian and English recorded, test Spanish slug: passed, with Spanish alone listed as missing. This is the scenario of an interruption after the second language.
  • English slug passed as the Italian one: rejected, because that slug is already recorded under a different language.
  • Same slug for two languages: rejected, because the three slugs must be distinct.
  • check-new on a recorded slug: rejected with a “do not duplicate” message.
  • Three new slugs: passed, three languages missing.

Rejected cases end with exit code 78. In the second case the check does not authorize starting from scratch: it only states what is left to do.

Where the check stops

  • The preliminary check reads the ledger, not the site. A post that was created but not yet recorded looks missing to it. That is why a resumed run first queries WordPress by slug, and the comparison inside the publishing script remains the last barrier.
  • It is not a transaction. Two parallel runs can both pass the preliminary check. What separates them is the lock, which works further down the line.
  • The comparison recognizes identical titles and slugs. The same topic rewritten under another title gets through: avoiding thematic repetition remains an editorial job.
  • The tests cover the answers of the preliminary checks. I did not deliberately interrupt a real publication and I did not trigger the concurrency lock.

A pair is not a set of three

Resuming only what is missing also matters for search engines. Google’s guidance on localized versions asks each version to list itself and all the others, and warns that annotations that do not point back to each other are ignored. A trilingual issue stuck at two languages should therefore be reported as partial and completed with the missing language only.

The logic is the one already seen for bylines in AI Lab: the author router that blocks a wrong byline: when automation is not sure of the state, it stops and says so.

In short

  • Three languages are three separate writes, and WordPress accepts a duplicate by adding a suffix to the slug.
  • Ledger, local manifest, lock and pre-creation comparison cover different moments of the same publication.
  • In six read-only tests on 15 November 2026 the preliminary checks recognized the complete set, the missing language and three wrong configurations.
  • The ledger can lag behind the site: before retrying, look at what actually exists.

AUTHOR

IT specialist, developer and systems engineer with a long history across code, Linux servers, retrocomputers and e-learning platforms. On AndroidLab he brings a technical, pragmatic eye: less brochure smoke, more attention to infrastructure, usability, privacy, updates and the real consequences of manufacturers' choices.

Leave a Comment