R-ArcGIS / r-bridge-install

Install the R ArcGIS Tools
Apache License 2.0
188 stars 59 forks source link

Frequent Cannot acquire a lock. errors #58

Closed bltern closed 3 years ago

bltern commented 6 years ago

I get persistent lock errors when trying to write to a File Geodatabase in R despite no other application accessing it. It seems to happen between when it creates the empty attribute table and when it's trying to load features into it so I end up with an empty feature class. This is particularly problematic when trying to do a bunch of writes. I have added sleep in between writes to see if this helps, but it doesn't seem to.

scw commented 6 years ago

@bltern thank you for your report. Could you share some example code that is triggering this problem? Are there any parallelization libraries in play like the parallel package? Does arcgisbinding report any specific error message, or just the message cannot acquire a lock as in the issue title?

Thanks, Shaun

bltern commented 6 years ago

Hi Shaun,

No parallelization libraries being used for this, but I am using MS R Open which has the advanced math libraries for using multiple cores when possible in R.  The error is only it cannot acquire a lock. Like I said it produces the empty table, but no features in it. Interestingly, when I just tried to do a merge in ArcGIS I encountered the same problem, though it said something about function problem and I think it's probably unrelated.

Sometimes (often) when I try to write the entire R Studio application crashes completely and needs to restart. This problem has gotten to be so pervasive that I've stopped using it recently in favor of writeOGR command to shapefiles, which is an undesirable but necessary outcome.

I think it happens when the File GDB get's corrupted, possibly by the cannot acquire a lock issue? It seems to go away for a time when I write to a new GDB (the crashing issue, not necessarily the lock issue).

As to code:

    gpspts_animal <- subset(gpspts, gpspts$Animal_ID == animal)

    animaltxt <- gsub(" ", "", animal)     # print(paste("Starting:", animal, "at", Sys.time()))

    ## export gpspts by animal as fc     print("beginning point writing.")     arc.write(path=file.path(BAEA_GDB, paste0("Cutler_2018BAEA", period, "_", animal_txt, "_pts")), gpspts_animal)

A pretty straightforward write routine. This is in a loop and it might do a couple but not the third. The errors show no real consistency so I'm a bit baffled. Let me know if you need more info, or to test anything specifically. I'd love to get this working reliably.

Cheers, Andrew

On 12/1/2017 10:57 PM, Shaun Walbridge wrote:

@bltern https://github.com/bltern thank you for your report. Could you share some example code that is triggering this problem? Are there any parallelization libraries in play like the |parallel| package? Does |arcgisbinding| report any specific error message, or just the message |cannot acquire a lock| as in the issue title?

Thanks, Shaun

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/R-ArcGIS/r-bridge-install/issues/58#issuecomment-348665967, or mute the thread https://github.com/notifications/unsubscribe-auth/AOafMRyo9NoaZUsO_KDTiEgKHip57elwks5s8MqkgaJpZM4Qyd1W.

-- Andrew Gilbert Data Management Director Biodiversity Research Institute 276 Canco Rd. Portland, ME 04103 207-839-7600 andrew.gilbert@briloon.org www.briloon.org

bltern commented 6 years ago

Here's what I get fully, hope it helps.

Error in .call_proxy("arc_export2dataset", path, data, coords, shape_info) : Cannot acquire a lock.

On 12/1/2017 10:57 PM, Shaun Walbridge wrote:

@bltern https://github.com/bltern thank you for your report. Could you share some example code that is triggering this problem? Are there any parallelization libraries in play like the |parallel| package? Does |arcgisbinding| report any specific error message, or just the message |cannot acquire a lock| as in the issue title?

Thanks, Shaun

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/R-ArcGIS/r-bridge-install/issues/58#issuecomment-348665967, or mute the thread https://github.com/notifications/unsubscribe-auth/AOafMRyo9NoaZUsO_KDTiEgKHip57elwks5s8MqkgaJpZM4Qyd1W.

-- Andrew Gilbert Data Management Director Biodiversity Research Institute 276 Canco Rd. Portland, ME 04103 207-839-7600 andrew.gilbert@briloon.org www.briloon.org

scw commented 6 years ago

Is it possible that it's trying to overwrite the same feature class in the loop? E.g. that the period + animal_txt fields will collapse down to the same value, and a subsequent overwrite is being asked for instead of a new feature being generated?

bltern commented 6 years ago

No. This should not be happening. I have gotten to successfully write using this very line of code, but not always. It's really baffling to me. I can't seem to predict what the issue is. I wonder if it's taking time for the empty featureclass to be written and trying to populate before it's released to do so? I am writing to a server so there will be some latency issues compared to writing locally if that is an issue. Just a thought.

On 12/5/2017 3:12 PM, Shaun Walbridge wrote:

Is it possible that it's trying to overwrite the same feature class in the loop? E.g. that the period + animal_txt fields will collapse down to the same value, and a subsequent overwrite is being asked for instead of a new feature being generated?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/R-ArcGIS/r-bridge-install/issues/58#issuecomment-349426730, or mute the thread https://github.com/notifications/unsubscribe-auth/AOafMXZQja5EY8n5nSJZ3KU6gCO4S01wks5s9aPKgaJpZM4Qyd1W.

-- Andrew Gilbert Data Management Director Biodiversity Research Institute 276 Canco Rd. Portland, ME 04103 207-839-7600 andrew.gilbert@briloon.org www.briloon.org

bltern commented 6 years ago

One more piece of the puzzle for helping resolve this. It appears that the Geodatabase must be getting corrupted during file writing operations because when I tried to export a layer in ArcMap to a Geodatabase that I could not acquire a lock in R, the same thing happened in ArcMap where it said the lock could not be acquired and it wrote out an empty Featureclass with no points in it. The errors says: Invalid function arguments Invalid function arguments Cannon acquire a lock. [GDB_Items] Cannot acquire a lock. The table was not found. [FC trying to be written] The table was not found. [FC trying to be written] The table was not found. [FC trying to be written] The table was not found. [FC trying to be written]

Very weird. Hopefully that's helpful.

orhuna commented 3 years ago

@bltern does this issue still persist with v244? We made some changes since this original issue to arc.write, including a bug fix with the overwrite parameter.

bltern commented 3 years ago

@orhuna I have not been having this crashing problem and use the arc.write function all the time. I have had some lock issues but they may have been related to having ArcCatalog open. I think this is resolved but I need to pay more attention. I think largely it's fine and the overwrite also seems to be working now. I had to delete and write again. All in all it's working well, but will comment if I see any persistent issues. Thanks for work on this.

orhuna commented 3 years ago

@bltern good to hear the issue is resolved. Please let us know if any other issues come up. Closing this issue.