eclipse-cdo / cdo

Eclipse Public License 1.0
2 stars 5 forks source link

Locks may never be released after a network loss #46

Open vsennedot opened 6 months ago

vsennedot commented 6 months ago

After a network loss and using reconnecting session, locks may never be released unless restarting the server. I can't produce a test case as it requires a network loss in a non-programmatic way, but here is some steps to reproduce:

1) Have a client remotely connected to a server with a reconnecting CDO session.

2) Lock an element by the client.

3) Simulate a network loss (by disabling the network card, for example). -The client session waits until the connection is restored. -The server doesn't seem to react and considers the session still connected.

4) Restore the network connection. -The reconnecting session requests a session opening with the same ID as before. -The SessionManager on the server creates a new session with this ID. The sessions map still have the previous session with this ID and when the new session is put in the map, the old session is replaced and isn't referenced anymore by the SessionManager but still remains open and keeps the locks.

5) Disconnect and reconnect the client. -The element locked in 2) appears locked and can't be unlocked.

vsennedot commented 2 months ago

I could add that I am able to fix this if I extends SessionManager and overrides the createSession method:

protected InternalSession createSession(int id, String userID, ISessionProtocol protocol) {
    InternalSession previousSession = getSession(id);
    if (previousSession != null) {
        previousSession.close();
    }

    return super.createSession(id, userID, protocol);
}