Re: MvLOCKFILE (was: Adding fields to a database )
The second script calling does not need to use the MvLOCKFILE command.
Empresa is already performing this.
<snip>
"As indicated in the database sections, when you are adding (<MvADD>) or
updating (<MvUPDATE>) a database record, Miva automatically prevents the
same record from being updated by more than one process at the same time. No
other Miva Script process can access a record while it is locked. "
... And in the database section:
"Database and index files are locked at the record level automatically when
records are added or updated to prevent data corruption (that is, two
programs cannot update the same record at the same time). Entire files can
be locked using <MvLOCKFILE>."
</snip>
Even though the manual refers to a "record lock" and a "file lock",
I don't believe there is any difference in what Empresa is doing.
FYI: I know the caching bug affects databases
(as per the original test script <A HREF ="http://www.becoded.com/lockfile_test.txt)">http://www.becoded.com/lockfile_test.txt)</A>
I have not run these tests using read/write from a text file....so not sure if
this would be affected also.
(i.e. second script doesn't see line updated/added by first script)
-Brian
Burns Enterprises
On Wed, 23 Feb 2005 17:35:39 -0500, Bill Matlock
<[email protected]> wrote:
> Brian,
>
> > I think you're misunderstanding the issue.
> > If you lock a .dbf, then try to read/write to it from another
> > script, the script "will" wait until the lock is released.
>
> Even if the "other" script does not use a lock? This is where I'm fuzzy on
> the issue of MvLOCKFILE.
>
> Quote:
> "However, if the second process does not issue an <MvLOCKFILE> before
> attempting to access the file in question, there is nothing to prevent this
> access from taking place. For this reason, we refer to the action of
> <MvLOCKFILE> as a lock request, rather than a lock: it is a request to other
> Miva Script processes that they 'respect' the current process's request for
> exclusive access. Another way of looking at this
> is: <MvLOCKFILE> does not interact with any other Miva Script tag, only
> other <MvLOCKFILE>s."
>
> So, according to this, the 2nd script will need a lock in order for it to
> wait for the 1st script's lock to be released. If the 2nd script was just a
> simple read, it would still require a lock for it to wait for the first
> script's lock to be released? And if so, my sometimes unlogical mind tells
> me that in order to always have a lock "trully" lock a file, all database
> operations would need to be inside a lock as well, because - "<MvLOCKFILE>
> does not interact with any other Miva Script tag, only other <MvLOCKFILE>s".
>
> Sorry if I'm confusing the issue, but this whole lockfile thing has always
> given me fits.
>
> Thanks,
> Bill M.
>
The second script calling does not need to use the MvLOCKFILE command.
Empresa is already performing this.
<snip>
"As indicated in the database sections, when you are adding (<MvADD>) or
updating (<MvUPDATE>) a database record, Miva automatically prevents the
same record from being updated by more than one process at the same time. No
other Miva Script process can access a record while it is locked. "
... And in the database section:
"Database and index files are locked at the record level automatically when
records are added or updated to prevent data corruption (that is, two
programs cannot update the same record at the same time). Entire files can
be locked using <MvLOCKFILE>."
</snip>
Even though the manual refers to a "record lock" and a "file lock",
I don't believe there is any difference in what Empresa is doing.
FYI: I know the caching bug affects databases
(as per the original test script <A HREF ="http://www.becoded.com/lockfile_test.txt)">http://www.becoded.com/lockfile_test.txt)</A>
I have not run these tests using read/write from a text file....so not sure if
this would be affected also.
(i.e. second script doesn't see line updated/added by first script)
-Brian
Burns Enterprises
On Wed, 23 Feb 2005 17:35:39 -0500, Bill Matlock
<[email protected]> wrote:
> Brian,
>
> > I think you're misunderstanding the issue.
> > If you lock a .dbf, then try to read/write to it from another
> > script, the script "will" wait until the lock is released.
>
> Even if the "other" script does not use a lock? This is where I'm fuzzy on
> the issue of MvLOCKFILE.
>
> Quote:
> "However, if the second process does not issue an <MvLOCKFILE> before
> attempting to access the file in question, there is nothing to prevent this
> access from taking place. For this reason, we refer to the action of
> <MvLOCKFILE> as a lock request, rather than a lock: it is a request to other
> Miva Script processes that they 'respect' the current process's request for
> exclusive access. Another way of looking at this
> is: <MvLOCKFILE> does not interact with any other Miva Script tag, only
> other <MvLOCKFILE>s."
>
> So, according to this, the 2nd script will need a lock in order for it to
> wait for the 1st script's lock to be released. If the 2nd script was just a
> simple read, it would still require a lock for it to wait for the first
> script's lock to be released? And if so, my sometimes unlogical mind tells
> me that in order to always have a lock "trully" lock a file, all database
> operations would need to be inside a lock as well, because - "<MvLOCKFILE>
> does not interact with any other Miva Script tag, only other <MvLOCKFILE>s".
>
> Sorry if I'm confusing the issue, but this whole lockfile thing has always
> given me fits.
>
> Thanks,
> Bill M.
>
Comment