Select to view content in your preferred language

Problems with locking tables

4399
10
05-02-2013 12:18 AM
teamIgal
Deactivated User
Hello,

I am using file geodatabase api 1.3.
I am not sure what is the proper way to use SetWriteLock() on tables in the GDB.

we are using one instance of the table in the code, and on that instance we read and write data on different places.

before i preform an insert or update on the table i set "SetWriteLock() " and after that "FreeWriteLock()", and still i get exception of "Cannot aquire a lock" when i reach to this line.

Why is that happening?

Thanks,
Igal team
0 Kudos
10 Replies
VinceAngelo
Esri Esteemed Contributor
Please provide the smallest possible code sample that exhibits the problem
(preferably using the data samples provided with the API).

- V
0 Kudos
LanceShipman
Esri Regular Contributor
SetWriteLock and FreeWriteLock modifies locking behavior. If they are not used, a write lock will be set and released for each insert or update. In a loading situation this is very slow. SetWriteLock sets a write lock until the free is called. This is much faster when doing bulk loads. As Vince indicates we need to see a short as possible piece of code that reproduces your issue.
0 Kudos
teamIgal
Deactivated User
Thanks for the quick reply.
I was trying to solve the issue by myself but with no luck.

I have difficulties providing code samples, but i will try to explain the situation:

We have MPK file that references a GDB file called Layers.GDB
In the solution we have a mapControl that loads the MPK and shows the layers.

Then we have a singleton class that Opens some of the tables from the GDB. most of the tables are not feature classes and dont contain geography objects.

In the code i have a few table.insert(NewRow) commands. sometimes (Not always) we are getting an exception in these lines with the exception:
FileGDBException was caught
Cannot aquire a lock
0 Kudos
teamIgal
Deactivated User
Hi, i am still having the same problems, with no idea how to solve this.

Can you please provide any help?

Thanks,
Team Igal
0 Kudos
VinceAngelo
Esri Esteemed Contributor
Please make it possible for us to help you by providing the requested code
(not your application, but a sample using the same calling sequence which
produces the same error with existing [or very simple] data).

- V
0 Kudos
AmitSaini
Emerging Contributor
Hi

1) I am opening a feature class as a table to update,
2) Setting the lock,
3) Updating table,
4) Freeing the lock,
5) Closing the table.


There is no issue in this operation.
But to check my updates when I am opening the feature class in Arc Catalog ( in Arc Map also) , Some error is coming.
However after closing the geo database and freeing the objects used , I am able to see the data in both applications.

Is it possible by any means to check the updates in between ?
0 Kudos
LanceShipman
Esri Regular Contributor
What versions of the API and ArcGIS are you using? Can you post your code?
0 Kudos
AmitSaini
Emerging Contributor
Esri.FileGDB.Table parcelTable = null;

   parcelTable = geodatabase.OpenTable(argParcelFeatureClassName);

   parcelTable.SetWriteLock();

   rowsParcels = parcelTable.Search(firstColumn, parcelTableWhereClause, RowInstance.Recycle);

                  
   foreach (Esri.FileGDB.Row parcelRow in rowsParcels)
   {                       
                              
   parcelRow.SetString"ColumnName1","Value1");

   parcelRow.SetDouble("ColumnName2", "Value2");

   parcelTable.Update(parcelRow);                          
                       
   }

   parcelTable.FreeWriteLock();

         FileGDB API Versions (According to dll properties in Visual Studio 2010)--

  Version : 1.3.0.143

         Run Time Version : v4.0.30319

  ArcGIS Version : 10.1
0 Kudos
AmitSaini
Emerging Contributor
Hello Lance

Do you need more information to answer my question ?
0 Kudos