Select to view content in your preferred language

Cannot delete version created with python tool

7892
16
02-19-2015 11:41 AM
MatthewLueders
Deactivated User

I am having an issue where I cannot delete a version because it is said to still be in use, but this error only arises when I use the script from an ArcGIS Tool in the Toolbox.  When I run the script from an outside IDE, or even the same commands from the python window, it finishes without error.

The general process is:

1) create a new version "Child"

2) Loop of feature classes:

    2.1) create feature layer

    2.2) change to version "Child"

    2.3) various queries etc

    2.4) copy feature layer

    2.5) change to version Default

3) run arcpy.ClearWorkspaceCache_management()  [updated]

4) delete version "Child" --- arcpy.DeleteVersion_management(sde_database, "username".Child)

The error returned by the tool dialogue is:

Executing: DeleteVersion "/path/connectionfile.sde" "username".Child

Start Time: Thu Feb 19 13:12:24 2015

ERROR 999999: Error executing function.

The version is currently in use. ["username".Child]

Failed to execute (DeleteVersion).

At this point I will go to the Version Manager to delete the Child version manually and I get the following error:

Could not delete version "username".Child.

[An event was unable to invoke any of the subscribers (Exception from

HResult: 0x80040201)]

If I close and reopen ArcMap I can then delete the version. Does anyone have an idea what might be causing this and how to resolve it?

0 Kudos
16 Replies
MatthewLueders
Deactivated User

It's a public version.  I just can't connect to it from a stand-alone script.  That's another approach to resolving this, I guess, if I didn't need the additional version.  I just haven't been able to find a way to connect to that version directly. Specifying the other "Username.version" doesn't work.

0 Kudos
MatthewLueders
Deactivated User

I missed one of your questions:

Oh, so the version you make is created under another version that has changes you want to see?

Yes

Were you using arcpy.ChangeVersion_management() to change versions?

Yes

Can the changes in the parent version be posted up so you can just do the script work on Default?

No

0 Kudos
MatthewLueders
Deactivated User

Reconciling didn't seem to help.  Good thought though.

0 Kudos
MattFrancis
Occasional Contributor

I am stuck in the same spot.  Did you figure out what was holding the connection open?

0 Kudos
JBeasley
Occasional Contributor

@MattFrancis I know this is a very old thread, but did you find a solution to this? Here is an outline of my process-

  • Create version from Default (named "massUpdate", access is private, owned by the user I am actively connected as and will perform all subsequent steps)
  • Make a feature layer of my dataset
  • Change version of the feature layer to newly created child version
  • Delete rows on feature layer
  • Append rows to feature layer
  • Change the feature layer's version back to Default
  • Clear workspace cache
  • Delete feature layer
  • Reconcile massUpdate with Default
  • Post massUpdate to Default
  • Delete massUpdate (this fails, saying it is in use)

 

I have tried deleting the version in the ReconcileVersions functions and as its own function- same result, says it is in use and cannot delete.

Thanks! 

0 Kudos
MattFrancis
Occasional Contributor

Sorry... I don't remember what I was doing, but we have a lot of weird things in our ecosystem. I very likely took another approach and left this idea hanging.

0 Kudos
JBeasley
Occasional Contributor

I actually got it this morning. In case it helps anyone else...

  • Create version from Default using the "dataUpdates" user (named "massUpdate", access is private, owned by the dataUpdates I am actively connected as and will perform all subsequent steps)
  • Make a feature layer of my dataset
  • Change version of the feature layer to massUpdate child version
  • Delete rows on feature layer
  • Append rows to feature layer
  • Connect as the database admin (I used SDE)
  • List users, look for dataUpdates user, and disconnect them (must use the admin connection to disconnect)
  • Reconcile massUpdate with Default using the admin connection
    • This failed if I tried to reconcile and post using the dataUpdates user, throwing an error of invalid workspace type. I get I just disconnected the user to remove the version lock, but I am still surprised it would not let me reconnect and rec and post. Note, I do not block connections.
  • Post massUpdate to Default
  • Delete massUpdate (this fails, saying it is in use)
0 Kudos