I need to disconnect users periodically to conduct geodatabase maintenance and programmatically update feature classes, but do not want to risk losing data when it is being actively edited or when a user may have edits in an open version that has not yet been posted.
Esri advises against disconnecting active sessions: Manage geodatabase locks—Help | ArcGIS for Desktop
Use caution when disconnecting users. Esri recommends that you avoid disconnecting active sessions, especially if the connected user is in the process of editing. You should only disconnect users to drop locks if a session was left open even when not being used (for example, over the weekend), if a session is orphaned and locking an object, or if a deadlock situation occurs.
It's pretty clear that being in an edit session is "in the process of editing". However, what is less clear how this prohibition applies to open versions not in an active edit session but with edits that have not yet posted to their parent version (dbo). If I disconnect a user with their unposted version open and then run maintenance actions like Compress, Analyze Datasets, and Rebuild Index, do I risk losing the data in their version?
It's easy to see what users are currently connected to an enterprise geodatabase. The following article details the process of using either ArcCatalog or ArcPy to list users.
How to identify the nature of the connection? It's all in the lock type. The following article details the three types of locks: schema, state, and version.
The above article states that version locks indicate an active edit session. State locks are when a version is simply open. Clearly, disconnecting a session with a version lock risks data loss. However, is the same true for State locks?