The rows never be locked permanently. Locks are based on session. If the session got disconnected or killed all locks will be released. Why not you try a dummy column on the same table to identify what rows are selected . And based on the dummy column status you can identify the rows in your second session.