comp.lang.ada
 help / color / mirror / Atom feed
From: Emmanuel Briot <briot.emmanuel@gmail.com>
Subject: Re: Single-Instance Executable, TSR-style programs, "lockfiles" and the DSA
Date: Fri, 10 Sep 2021 00:10:49 -0700 (PDT)	[thread overview]
Message-ID: <71d68159-3f72-4949-bc4f-ef83f8cd7067n@googlegroups.com> (raw)
In-Reply-To: <db3d27e9-fbc1-423e-8ae0-6ebaf024f8een@googlegroups.com>

When I wrote the program that processes all incoming email on the mailing lists at AdaCore (in particular to manage tickets), we were using lockfiles indeed to coordinate between all the instances of the program (one per incoming email). The lockfile contained an expiration date and the PID of the process that took the lock, and a program was allowed to break the lock when that date was reached (like 10min or something, I forgot the value we came up with, when processing one message takes a few milliseconds), or when the process no longer existed (so crashed). So at least the system could not totally break and would eventually recover.

This is of course far from perfect, since during those 10 minutes no email could be processed or delivered, and if the timeout is incorrect we could end up with two programs executing concurrently (in practice, this was not a major issue for us and we could deal with the once-a-year duplicate ticket generated).

Years later, we finally moved to an actual database (postgresql) and we were able to remove the locks altogether by taking advantage of transactions there. This is of course a much better approach.

When I look at systems like Kafka (multi-node exchange of messages), they have an external program (ZooKeeper) in charge of monitoring the various instances. Presumably a similar approach could be used, where the external program is much simpler and only in charge of synchronizing things. Being simpler and fully written in Ada, it would be simpler to ensure this one doesn't crash (famous last words...).

  reply	other threads:[~2021-09-10  7:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-08 21:23 Single-Instance Executable, TSR-style programs, "lockfiles" and the DSA Shark8
2021-09-10  7:10 ` Emmanuel Briot [this message]
2021-09-10 16:26   ` Shark8
2021-09-11  7:42     ` Emmanuel Briot
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox