{
  "id": 22968142,
  "title": "Your nightly OPTIMIZE and your streaming MERGE are fighting over the same files",
  "url": "https://urgent.news/2026/12/01/your-nightly-optimize-and-your-streaming-merge-are-fighting-over-the",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-12-01T15:01:11.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/arka_ghosh_dda0d0cfefcf68/your-nightly-optimize-and-your-streaming-merge-are-fighting-over-the-same-files-2plg"
  },
  "original_language": null,
  "account": "A maintenance job that optimizes the \"silver_events\" table is failing nightly due to concurrent modification errors. The issue is not with the maintenance notebook or the jobs themselves, but rather the timing of when they run. The streaming job feeding the same table has become busier, causing conflicts between the two jobs.\n\nUnlike SQL Server, Delta uses optimistic concurrency, meaning both writers can proceed simultaneously. The one that commits second checks whether the files it read are still current. If not, it fails, leading to the concurrent modification error. This is not a queue, but a race condition between the two jobs.\n\nTo fix the issue, the maintenance job should only optimize a specific partition of the table, using a partition predicate. This ensures that the job only rewrites files in the recent partitions, which the streaming MERGE has already finished writing to. By doing so, the two jobs no longer rewrite the same files, eliminating the possibility of a collision.\n\nAdditionally, the maintenance job should use the ZORDER BY clause to improve query performance. Partitioning on a high-cardinality column can create millions of tiny folders, leading to poor query performance. Z-ordering, on the other hand, co-locates each customer's rows into a few files within each event_date partition, allowing the filter to skip most files and improving query performance.\n\nIn summary, the concurrent modification errors are caused by the timing of the streaming MERGE and the maintenance job rewriting the same files. By optimizing only a specific partition of the table, using a partition predicate, and employing Z-ordering, the two jobs can run concurrently without conflicts, and the maintenance job will no longer fail.",
  "summary": "The maintenance notebook is three lines, it ran fine for a month, and now it fails most nights with a concurrent modification error. Nothing changed in the notebook. What changed is that the streaming job feeding the same table got busier. -- nightly maintenance notebook (Spark SQL), 02:00 OPTIMIZE silver_events ; VACUUM silver_events ; DESCRIBE HISTORY silver_events LIMIT 5 ; Why it only breaks…",
  "summary_source": "publisher",
  "key_points": [
    "Maintenance job fails nightly due to concurrent modification errors",
    "Streaming job feeding same table becomes busier, causing conflicts",
    "Optimize specific partition with partition predicate to resolve issue"
  ],
  "editors_take": null,
  "opinion": false,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "machine_translated": false,
  "ai_generated": true,
  "disclaimer": "Accounts, briefs, key points, the editor’s take and translations are written by software from other outlets’ reporting and may contain errors. A summary whose summary_source is \"publisher\" is the outlet’s own feed text. Always check the linked original."
}