Opened 5 years ago

Closed 3 years ago

#235 closed defect (fixed)

Race condition in install command -> The segment has been deleted

Reported by: Eric Swenson Owned by: Eric Swenson
Priority: major Milestone: MR12.8
Component: Answering Service Version: MR12.7
Keywords: Cc:

Description

If you use the install command multiple times in succession, as in the following command:

install (Terminals Operator HFED).pdt

You can get the following error:

Error:  Segment-fault error by >user_dir_dir>SysAdmin>Repair>install_bug>install|2062 (line 254)
referencing 431|10
The segment has been deleted.
r 07:25 0.463 3 level 2

This is presumably because "install" writes to the >sc1>update directory and Initializer installs the segment and then deletes the file. Install creates a shriek-named segment in the >sc1>update directory, and then writes to it. The race condition is most likely that when the first segment is written to >sc1>update and Initializer is notified that there is something to update, it takes a little time before Initializer processes the segment and deletes it. Before Initializer has a chance to do that, the install program (having been invoked multiple times in rapid succession) writes another segment into >sc1>update, but before it can actually writes its content, Initializer wakes up, processes BOTH segments (getting an error on the second because it hasn't been written yet), and deletes both segments. Then, when "install" tries to write to the >sc1>update segment that it created, it has already been deleted by Initializer.

Change History (5)

comment:1 by Eric Swenson, 5 years ago

Component: GeneralAnswering Service
Version: MR12.7

comment:2 by Eric Swenson, 5 years ago

Another data point that confirms the above analysis: This message appears on the Initializer console:

 0720  as   up_sysctl_: Unable to install \000\000\000\000 for Repair.SysAdmin.a. userid should be \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000

This shows that the created in >sc1>update, but not yet written to is "incomplete".

comment:3 by Eric Swenson, 5 years ago

A simple solution to the problem is this:

Change the install command to create segments in >sc1>update with a suffix (e.g. .lock) and change up_sysctl_ to ignore these when Initializer gets a event over the install channel). When install has completely written the table into the .lock segment, have it make a call to rename the segment to remove the .lock suffix, and wakeup Initializer.

comment:4 by Eric Swenson, 5 years ago

Gary suggests using a suffix of ".pre-install" rather than ".lock" as ".lock" is overused and suggests use of the locking primitives in Multics.

comment:5 by Eric Swenson, 3 years ago

Milestone: MR12.8
Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.