Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
INSERT INTO locking mecanism
Message
De
05/09/1997 18:40:11
 
 
À
05/09/1997 16:09:20
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00048697
Message ID:
00048781
Vues:
34
>>>>>>I assume you are inserting into a table from an array of many rows. You may need to try testing FLOCK(). If you can lock the table you can insert with no problem.
>>>>>
>>>>>I guess this is what I'll have to implement. This happen more and more that 2 users are creating a Universal Thread message at the same time.
>>>>>
>>>>>First, I'll have to SET REPROCESS TO AUTOMATIC. Then, I'll implement the FLOCK().
>>>>>
>>>>>Here is an example of my command:
>>>>>
>>>>>INSERT INTO TableName;
>>>>> (IDField,Field1,FieldDate,FieldTime);
>>>>> VALUES (lnNewRec,lnField1Value,DATE(),TIME())
>>>>
>>>>This is unusual. You are only inserting 1 record at a time yet still get an occassional collision. I would have thought a reprocess time of 2 seconds would have been more than enough time to insert a record, update a CDX (if any), and unlock the table header. May have something to do with the enormous file size your table must be after a year of UT messages.
>>>
>>>Well, I have multiple instances of the Visual FoxPro application on the server. Right now, I have 2 which means, sometimes, I have collision. Also, the mailing list application is using the same command, so we have 3 application. So, collisions do occur.
>>>
>>>Yes, the tags need to be updated but this shouldn't take more than 2 minutes, which happened this morning. In fact, if the Web server wouldn't have a 2 minutes timeout, who knows how long it would have taken to execute this command.
>>>
>>>As mentioned to Ed, I will start with AUTOMATIC. If I still have the same behavior, I'll add the FLOCK mecanism.
>>>
>>>I'm using PHDBase which has a tag on that table. Might it be the problem?
>>
>>I have a screen that 6 users use concurrently all day long, solely for data entry. Every time a new member application is entered and saved, a method creates and inserts at least 3 records into a child table. This particular form has been in operations for a little over a month, with a new app being entered about once a minute on each machine. (about 18 INSERTs/min) and I have seen the 'file is in use by another' error twice. When one user gets it, they all get it, and the table seems to be locked in a deadly embrace; no one can even get to any other records until they close their datasession and reenter. REPROCESS is set to 15 seconds. I would have set it to automatic, but my system can't afford to skip an insert because the user hit escape.
>
>I believe that Insert-Sql locks the header of the table inserted and the record locks any aliased table. Is it possible that foxpro locks what it can and waits for locks on the rest? In this case two users would wait forever if one had one of the tables locked and another had one or more of the tables locked. I make it a practice to save all aliased fields to memory variables and then do the insert. That way I am only locking one table or record and the infinite wait is not possible. I ran a test:
>
>select 0
>use MyTable
>do while .t.
> insert into MyTable(field) values(value)
>enddo
>
>I ran this in two instances of vfp with reprocess set to 2 and never had a problem

Is your table locally? If yes, the test will always work. Do the same test with a table on a server and the two instances on different stations. I'm almost sure it will fail (rare, but it will) when the network is very loaded (it depends also on the type of the network).

Vlad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform