code: public void checkLocksInDataBase(boolean autoRepair)
     {
        SecurityHelper.validateSecurityPermission(JCRRuntimePermissions.MANAGE_REPOSITORY_PERMISSION);
  
        ResultSet resultSet = null;
        PreparedStatement preparedStatement = null;
        Connection jdbcConnection = null;
        try
        {
           jdbcConnection = jdbcDataContainer.getConnectionFactory().getJdbcConnection();
           preparedStatement = jdbcConnection.prepareStatement(lockInspectionQuery.getStatement());
           resultSet = preparedStatement.executeQuery();
  
           Set<String> lockedInJCRITEM = new HashSet<String>();
           while (resultSet.next())
           {
              lockedInJCRITEM.add(removeWorkspacePrefix(resultSet.getString(DBConstants.COLUMN_PARENTID)));
           }
  
           Set<String> lockedInJCRLOCK = lockHandler.getLockedNodesIds();
  
           checkConsistencyInJCRITEM(lockedInJCRITEM, lockedInJCRLOCK, autoRepair);
           checkConsistencyInJCRLOCK(lockedInJCRITEM, lockedInJCRLOCK, autoRepair);
        }
        catch (SQLException e)
        {
           logExceptionAndSetInconsistency("Unexpected exception during LOCK DB checking.", e);
        }
        catch (NamingException e)
        {
           logExceptionAndSetInconsistency("Unexpected exception during LOCK DB checking.", e);
        }
        catch (RepositoryConfigurationException e)
        {
           logExceptionAndSetInconsistency("Unexpected exception during LOCK DB checking.", e);
        }
        catch (RepositoryException e)
        {
           logExceptionAndSetInconsistency("Unexpected exception during LOCK DB checking.", e);
        }
        finally
        {
           JDBCUtils.freeResources(resultSet, preparedStatement, jdbcConnection);
        }
     }
docs: Checks jcr locks for consistency. Defines if there is a node with lockIsDeep or lockOwner property
  (basically means that the node is to be locked)
  and has no corresponding record in LockManager persistent layer (db table);
  or the opposite.