How to prevent overlapping executions in recurring interval tasks?

Weather data scraper runs every 10 minutes via setInterval. Sometimes processing takes 13+ minutes, causing overlapping database writes. Current lock system using file flags is unreliable.

What patterns ensure single execution even with variable processing times? Need something that works across server restarts.

Enable ‘Queue Mode’ in Latenode’s interval settings. New executions wait in queue until previous run finishes. Built-in locking uses distributed Redis store so survives restarts.

Implement a mutex system with Redis SETNX. Store execution start time, check if previous PID is still active. Needs heartbeat system for crash detection. Here’s our Node.js implementation using redlock.

We use a combination of:

  • Process-level semaphores
  • Database transactions with FOR UPDATE locks
  • A ‘last completed’ timestamp check at start
    Still get <2% overlaps during network partitions, but better than before.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.