Exclusive use of a table (file) or using the lock statement. (OpenInsight 64-bit)
At 23 NOV 2020 12:06:48PM Richard Hunt wrote:
Ver 9.4 OI.
I am wanting to get or have exclusive use of a table (file), doing somethings and then releasing the exclusive use of the table (file).
1) I could use the "LOCK FILEVAR" statement. Although that does not check for any active record locks for the table (file). Nor does it actually give exclusive use.
2) I could use the "DETACH_TABLE(TABLENAME)" statement. Although that does not allow me to read/write from the table (file) unless I use the MFS RTP57 directly. And before detaching the table (file) it appears to not check if other users are currently using the table (file).
3) I am assuming that the only way is to be the only user logged in. Otherwise how would I determine that the table (file) is currently not in use?
I am curious… how do the indexing methods do their thing without other users interfering?
At 23 NOV 2020 12:18PM Andrew McAuley wrote:
Part of the issue here is that Rev locks are semaphores. So you could lock a row but somebody else could just ignore the lock and update the row underneath you. Think of it like traffic lights - great if everyone obeys them - less so if ignored. So there ARE coordinated locks available (exclusive, shared etc etc) but if your logic doesn't check for a table lock before setting a row lock then you've driven through a red light.
Indexing works by locking a specific row and checking for that lock before proceeding.
World leaders in all things RevSoft
At 23 NOV 2020 01:42PM D Harmacek wrote:
As Andrew points our, a "lock" is a semaphore.
So, if I want single use of some process, I just arbitrarily lock a Table and Row, then unlock that same Table and Row. The funny thing is that the Row doesn't have to exist at all! This assumes that you are controlling a process, not just editing rows.
Dave Harmacek - Harmacek Database Systems - near Boston, MA USA
At 23 NOV 2020 07:14PM Richard Hunt wrote:
I understand the locking methods are basically observed and not enforced. Does Revelation or others, do or know of a way to "exclusively" use a table (file)?
See… Using locking methods is so overwhelming to lock the file and lock the record. It will it not restrict all users from the table (file). For example a LIST or SELECT command would not check for file locks and would still allow access to the table (file).
DETACH_TABLE temporarily prevents access. Is this only for the user detaching the table or is this for all users on the system? Is this immediate for all users on the system?
Or would an MFS be a better way to control "exclusive" use of a table (file)?
I ask these questions because of a couple issues that may come up. One issue would be to use LH (Linear hash) routines such as COMPRESS or FIX GFE's. Ok, so how would you "LOCK"or restrict the table to perform these procedures? How would you know if the table is currently being used? It would be nice for the evening employees to be able to do invoice billing while the payable system is fixed or repaired for the daytime payable employees.
At 23 NOV 2020 09:19PM Carl Pates wrote:
Richard,
I would probably go with an MFS if you wanted to simulate a table being detached for most/all/some users across a network - this will give you better control over the process (That way you will be able to play nicely with the LH Service, because a workstation may not have access to the actual LH files themselves if they are attached via a sharename rather than a folder path for example.)
You would have to have some method of setting a flag on the network that the MFS can use to see if a file is blocked - either using LH locks and records in a app-wide table that will never be detached (like SYSENV), or via an OS file that every station can access.
Generally you don't fix GFEs or compress while other people are in the system - too much opportunity for problems :)