[GIS] Avoiding dbo.arcsde LOCK issue while exporting to ArcSDE

enterprise-geodatabaselock

I had a spatial db connection open in arcmap. While exporting to SDE with a console app I get an error in the console:

Lock request conflicts with an established lock [DBO].

Does this just mean someone is using the same ArcSDE connection or is it the feature dataset?

Of course when I closed arcmap, and fired the console app again, my feature class exported to ArcSDE successfully.

Can I kill any locks programmatically if I am DBO (when other users are using the same FD)?

If that's not smart, how can I avoid this lock?

How does the GIS community deal with this issue, wait till all users are off and run it at 2am?

The console app will become a batch process updating FCs on a regular basis.

Best Answer

Your console app has its own connection since it is running on a different process - there is no "sharing of connections" in that use case.

Anytime ArcMap connects and opens a dataset, it creates a shared schema lock on a FC (and all related versioning, history, relationship clases, etc, tables). This is just to make sure that the schema doesn't change. Another thing to keep in mind is that if you open a FC inside FeatureDataset, this will cause your workspace to get a shared lock of all the FCs inside that FD as well.

On the other hand, exclusive locks are used for DDL operations (i.e. changing schema).

So I assume that your "load" operation is actually dropping the entire table (a schema change) and then recreating the table. For that, you would need an exclusive schema lock.

Consider just truncating the table using sdetable –o truncate before loading the new one. You may not need to kick anyone out.

Oh yeah, and don't remove locks just because. If you are, kick the users out instead of changing locks underneath them which will lead to bad things.