When creating file names to pass to a policy (data file ~X, result file ~R and sentinel file ~S), Mercury (v. 4.72) seems to reuse file names rather than generating random names for each invocation of the policy. This causes a race condition that has bitten me a couple of times: the data file for a second invocation of the policy is given the same name as the result file of a first invocation. As a consequence, the first invocation generates a false exception (non-empty result file) and its result file is the actual data (CNM file) of the second invocation.
To verify this, I modified my policy so that it would also log the date, time and name of the ~X ~R and ~S files passed to it. Here's a small piece of that log:
DATE TIME ~X ~R ~S
03/01/11 20:21:30 c:\mtmp\LKVD2AYJ.TMP c:\mtmp\KYKVVWGR.TMP c:\mtmp\154BLXEM.TMP
03/01/11 20:21:51 c:\mtmp\KYKVVWGR.TMP c:\mtmp\SAAANORJ.TMP c:\mtmp\1XX95QL9.TMP
03/01/11 20:22:11 c:\mtmp\LKVD2AYJ.TMP c:\mtmp\KYKVVWGR.TMP c:\mtmp\154BLXEM.TMP
03/01/11 20:22:43 c:\mtmp\W0IAKS6M.TMP c:\mtmp\154BLXEM.TMP c:\mtmp\LKVD2AYJ.TMP
03/01/11 20:22:43 c:\mtmp\W0IAKS6M.TMP c:\mtmp\154BLXEM.TMP c:\mtmp\LKVD2AYJ.TMP
03/01/11 20:22:44 c:\mtmp\W0IAKS6M.TMP c:\mtmp\154BLXEM.TMP c:\mtmp\LKVD2AYJ.TMP
03/01/11 20:33:00 c:\mtmp\LKVD2AYJ.TMP c:\mtmp\KYKVVWGR.TMP c:\mtmp\154BLXEM.TMP
03/01/11 20:33:32 c:\mtmp\W0IAKS6M.TMP c:\mtmp\154BLXEM.TMP c:\mtmp\LKVD2AYJ.TMP
03/01/11 20:39:58 c:\mtmp\LKVD2AYJ.TMP c:\mtmp\KYKVVWGR.TMP c:\mtmp\154BLXEM.TMP
03/01/11 20:40:31 c:\mtmp\W0IAKS6M.TMP c:\mtmp\154BLXEM.TMP c:\mtmp\LKVD2AYJ.TMP
03/01/11 20:43:05 c:\mtmp\LKVD2AYJ.TMP c:\mtmp\KYKVVWGR.TMP c:\mtmp\154BLXEM.TMP
Just think about what would happen if the first invocation had not finished by the time the second invocation was called. The log for the whole day only has 6 or 7 different file names.
<p>When creating file names to pass to a policy (data file ~X, result file ~R and sentinel file ~S), Mercury (v. 4.72) seems to reuse file names rather than generating random names for each invocation of the policy. This causes a race condition that has bitten me a couple of times: the data file for a second invocation of the policy is given the same name as the result file of a first invocation. As a consequence, the first invocation generates a false exception (non-empty result file) and its result file is the actual data (CNM file) of the second invocation.</p><p>To verify this, I modified my policy so that it would also log the date, time and name of the ~X ~R and ~S files passed to it. Here's a small piece of that log:</p><p><font face="courier new,courier" size="2">&nbsp; DATE&nbsp;&nbsp;&nbsp;&nbsp; TIME&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ~X&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; ~R&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ~S</font>
</p><p><font face="courier new,courier" size="2">03/01/11 20:21:30 c:\mtmp\LKVD2AYJ.TMP c:\mtmp\KYKVVWGR.TMP c:\mtmp\154BLXEM.TMP
03/01/11 20:21:51 c:\mtmp\KYKVVWGR.TMP c:\mtmp\SAAANORJ.TMP c:\mtmp\1XX95QL9.TMP
03/01/11 20:22:11 c:\mtmp\LKVD2AYJ.TMP c:\mtmp\KYKVVWGR.TMP c:\mtmp\154BLXEM.TMP
03/01/11 20:22:43 c:\mtmp\W0IAKS6M.TMP c:\mtmp\154BLXEM.TMP c:\mtmp\LKVD2AYJ.TMP
03/01/11 20:22:43 c:\mtmp\W0IAKS6M.TMP c:\mtmp\154BLXEM.TMP c:\mtmp\LKVD2AYJ.TMP
03/01/11 20:22:44 c:\mtmp\W0IAKS6M.TMP c:\mtmp\154BLXEM.TMP c:\mtmp\LKVD2AYJ.TMP
03/01/11 20:33:00 c:\mtmp\LKVD2AYJ.TMP c:\mtmp\KYKVVWGR.TMP c:\mtmp\154BLXEM.TMP
03/01/11 20:33:32 c:\mtmp\W0IAKS6M.TMP c:\mtmp\154BLXEM.TMP c:\mtmp\LKVD2AYJ.TMP
03/01/11 20:39:58 c:\mtmp\LKVD2AYJ.TMP c:\mtmp\KYKVVWGR.TMP c:\mtmp\154BLXEM.TMP
03/01/11 20:40:31 c:\mtmp\W0IAKS6M.TMP c:\mtmp\154BLXEM.TMP c:\mtmp\LKVD2AYJ.TMP
03/01/11 20:43:05 c:\mtmp\LKVD2AYJ.TMP c:\mtmp\KYKVVWGR.TMP c:\mtmp\154BLXEM.TMP</font></p><p>Just think about what would happen if the first invocation had not finished by the time the second invocation was called. The log for the whole day only has 6 or 7 different file names.</p><p>
</p>