Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Nothing happens.


devel / comp.lang.ada / Re: Single-Instance Executable, TSR-style programs, "lockfiles" and the DSA

SubjectAuthor
* Single-Instance Executable, TSR-style programs, "lockfiles" and the DSAShark8
`* Re: Single-Instance Executable, TSR-style programs, "lockfiles" andEmmanuel Briot
 `* Re: Single-Instance Executable, TSR-style programs, "lockfiles" andShark8
  `- Re: Single-Instance Executable, TSR-style programs, "lockfiles" andEmmanuel Briot

1
Single-Instance Executable, TSR-style programs, "lockfiles" and the DSA

<db3d27e9-fbc1-423e-8ae0-6ebaf024f8een@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=5854&group=comp.lang.ada#5854

 copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a37:6253:: with SMTP id w80mr210806qkb.237.1631136238505;
Wed, 08 Sep 2021 14:23:58 -0700 (PDT)
X-Received: by 2002:a05:6902:124c:: with SMTP id t12mr406134ybu.91.1631136238314;
Wed, 08 Sep 2021 14:23:58 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Wed, 8 Sep 2021 14:23:58 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=146.5.2.231; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC
NNTP-Posting-Host: 146.5.2.231
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <db3d27e9-fbc1-423e-8ae0-6ebaf024f8een@googlegroups.com>
Subject: Single-Instance Executable, TSR-style programs, "lockfiles" and the DSA
From: onewinge...@gmail.com (Shark8)
Injection-Date: Wed, 08 Sep 2021 21:23:58 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 23
 by: Shark8 - Wed, 8 Sep 2021 21:23 UTC

I'm currently engaged in writing a series of programs for some scientists to control a few cameras; one system is a sort of cobbled together web-program, distributed across several computers [PHP for interface + C++ for mesage-slinging and camera-control], while the other is a single computer basically running the camera's manufacturer's program. -- This is mostly about the latter, though as the former will need to be addressed [via DSA(?)] in the near future.

There is another system that I'm not touching (for now) which uses lockfiles; sometimes (crashes and erroneous shutdowns) will leave the lockfiles behind. I have a controlled type-wrapper that will close its file if it is still open, and that could easily be adapted to delete them on finalization in the case of a lockfile. -- (#1) What is the best way that the community has come up with regarding lockfiles or similar functionality?

In this particular case, the lockfile represents that the control software for a particular instrument is already running, which brought to mind the old DOS TSRs where you would boot up the program and could call it (or another program using its services) again to achieve some different/special effects, which then brought to mind the new single-instance executables. Now, obviously the DSA can be used in this manner so that one partition provides services and the client partition queries/quits as needed. -- (#2) Is there a non-DSA, and hopefully portable, Ada way to achieve single-instance executables? [I haven't had any luck trying web-searches on this topic.]

Re: Single-Instance Executable, TSR-style programs, "lockfiles" and the DSA

<71d68159-3f72-4949-bc4f-ef83f8cd7067n@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=5866&group=comp.lang.ada#5866

 copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a37:652:: with SMTP id 79mr6603542qkg.197.1631257850099;
Fri, 10 Sep 2021 00:10:50 -0700 (PDT)
X-Received: by 2002:a5b:58e:: with SMTP id l14mr8702648ybp.143.1631257849711;
Fri, 10 Sep 2021 00:10:49 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Fri, 10 Sep 2021 00:10:49 -0700 (PDT)
In-Reply-To: <db3d27e9-fbc1-423e-8ae0-6ebaf024f8een@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=87.88.29.208; posting-account=6yLzewoAAABoisbSsCJH1SPMc9UrfXBH
NNTP-Posting-Host: 87.88.29.208
References: <db3d27e9-fbc1-423e-8ae0-6ebaf024f8een@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <71d68159-3f72-4949-bc4f-ef83f8cd7067n@googlegroups.com>
Subject: Re: Single-Instance Executable, TSR-style programs, "lockfiles" and
the DSA
From: briot.em...@gmail.com (Emmanuel Briot)
Injection-Date: Fri, 10 Sep 2021 07:10:50 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 25
 by: Emmanuel Briot - Fri, 10 Sep 2021 07:10 UTC

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...).

Re: Single-Instance Executable, TSR-style programs, "lockfiles" and the DSA

<3a1b8e39-daf8-4ae4-9e2e-6e4b76fa7a5dn@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=5867&group=comp.lang.ada#5867

 copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a37:8f04:: with SMTP id r4mr8272054qkd.351.1631291169286;
Fri, 10 Sep 2021 09:26:09 -0700 (PDT)
X-Received: by 2002:a25:4789:: with SMTP id u131mr11816957yba.531.1631291169027;
Fri, 10 Sep 2021 09:26:09 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Fri, 10 Sep 2021 09:26:08 -0700 (PDT)
In-Reply-To: <71d68159-3f72-4949-bc4f-ef83f8cd7067n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=146.5.2.231; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC
NNTP-Posting-Host: 146.5.2.231
References: <db3d27e9-fbc1-423e-8ae0-6ebaf024f8een@googlegroups.com> <71d68159-3f72-4949-bc4f-ef83f8cd7067n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <3a1b8e39-daf8-4ae4-9e2e-6e4b76fa7a5dn@googlegroups.com>
Subject: Re: Single-Instance Executable, TSR-style programs, "lockfiles" and
the DSA
From: onewinge...@gmail.com (Shark8)
Injection-Date: Fri, 10 Sep 2021 16:26:09 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 37
 by: Shark8 - Fri, 10 Sep 2021 16:26 UTC

On Friday, September 10, 2021 at 1:10:51 AM UTC-6, briot.e wrote:
> 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.
Interesting.
When you moved to DB, did you use the DSA to have a Database-interface partition and client-query/-interface partition? I'm assuming not, because such a ticketing system probably doesn't have enough need for distributed clients, report-generators, etc. to justify such a design.

> 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...).
I suspect such designs are consequences of the poor support for processes/tasking that C has; the Ada equivalent of the functionality would be to have a TASK dedicated to the DB-interfacing [assuming single-node]; for full multi-node DB-backed/-transacted message-exchange DSA makes a lot of sense: Partition your DB-interface into a single node, then have your clients remote-interface that node.

Re: Single-Instance Executable, TSR-style programs, "lockfiles" and the DSA

<1a3b3c31-03de-4ffc-bc5b-bbbb6e6c3734n@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=5876&group=comp.lang.ada#5876

 copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:ad4:468c:: with SMTP id bq12mr1284504qvb.21.1631346139885;
Sat, 11 Sep 2021 00:42:19 -0700 (PDT)
X-Received: by 2002:a25:d497:: with SMTP id m145mr2281727ybf.389.1631346139589;
Sat, 11 Sep 2021 00:42:19 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Sat, 11 Sep 2021 00:42:19 -0700 (PDT)
In-Reply-To: <3a1b8e39-daf8-4ae4-9e2e-6e4b76fa7a5dn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=87.88.29.208; posting-account=6yLzewoAAABoisbSsCJH1SPMc9UrfXBH
NNTP-Posting-Host: 87.88.29.208
References: <db3d27e9-fbc1-423e-8ae0-6ebaf024f8een@googlegroups.com>
<71d68159-3f72-4949-bc4f-ef83f8cd7067n@googlegroups.com> <3a1b8e39-daf8-4ae4-9e2e-6e4b76fa7a5dn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <1a3b3c31-03de-4ffc-bc5b-bbbb6e6c3734n@googlegroups.com>
Subject: Re: Single-Instance Executable, TSR-style programs, "lockfiles" and
the DSA
From: briot.em...@gmail.com (Emmanuel Briot)
Injection-Date: Sat, 11 Sep 2021 07:42:19 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 21
 by: Emmanuel Briot - Sat, 11 Sep 2021 07:42 UTC

> When you moved to DB, did you use the DSA to have a Database-interface partition and client-query/-interface partition? I'm assuming not, because such a ticketing system probably doesn't have enough need for distributed clients, report-generators, etc. to justify such a design.

We did not use the DSA. Postgres itself is a very capable server, which is implemented way more efficiently (and tested way better) than we could ever do I think, since this was only a side job. No reason to add an extra layer between the mail-processing program and the database.

> I suspect such designs are consequences of the poor support for processes/tasking that C has; the Ada equivalent of the functionality would be to have a TASK dedicated to the DB-interfacing [assuming single-node]; for full multi-node DB-backed/-transacted message-exchange DSA makes a lot of sense: Partition your DB-interface into a single node, then have your clients remote-interface that node.

I don't think you need a task dedicated to the database. Postgres handles concurrency very efficiently, it can do asynchronous queries if you really need that, and so on.
If you indeed have a database in your application, you could also use that to handle inter-process locking (pg_advisory_lock() for instance)

1
server_pubkey.txt

rocksolid light 0.9.7
clearnet tor