int findOrCreateRootRecord(@NotNull String rootUrl) throws IOException {
    rootsAccessLock.lock();
    try {
      PersistentFSConnection connection = this.connection;

      int rootUrlId = connection.getNames().tryEnumerate(rootUrl);

      int[] rootUrls = ArrayUtilRt.EMPTY_INT_ARRAY;
      int[] rootIds = ArrayUtilRt.EMPTY_INT_ARRAY;
      try (final DataInputStream input = attributeAccessor.readAttribute(SUPER_ROOT_ID, CHILDREN_ATTR)) {
        if (input != null) {
          final int rootsCount = DataInputOutputUtil.readINT(input);
          if (rootsCount < 0) {
            throw new IOException("SUPER_ROOT.CHILDREN attribute is corrupted: roots count(=" + rootsCount + ") must be >=0");
          }
          rootUrls = ArrayUtil.newIntArray(rootsCount);
          rootIds = ArrayUtil.newIntArray(rootsCount);
          int prevRootId = 0;
          int prevUrlId = 0;

          for (int i = 0; i < rootsCount; i++) {
            int urlId = DataInputOutputUtil.readINT(input) + prevUrlId;
            int rootId = DataInputOutputUtil.readINT(input) + prevRootId;
            if (urlId == rootUrlId) {
              checkChildIdValid(SUPER_ROOT_ID, rootId, i, connection.getRecords().maxAllocatedID());
              return rootId;
            }

            prevUrlId = rootUrls[i] = urlId;
            prevRootId = rootIds[i] = rootId;
          }
        }
      }

      connection.markDirty();
      rootUrlId = connection.getNames().enumerate(rootUrl);

      try (DataOutputStream output = attributeAccessor.writeAttribute(SUPER_ROOT_ID, CHILDREN_ATTR)) {
        final int newRootFileId = recordAccessor.createRecord(Collections.emptyList());

        final int index = Arrays.binarySearch(rootIds, newRootFileId);
        if (index >= 0) {
          throw new AssertionError("Newly allocated newRootFileId(=" + newRootFileId + ") already exists in root record: " +
                                   "rootIds(=" + Arrays.toString(rootIds) + "), rootUrls(=" + Arrays.toString(rootUrls) + "), " +
                                   "rootUrl(=" + rootUrl + "), rootUrlId(=" + rootUrlId + ")");
        }
        rootIds = ArrayUtil.insert(rootIds, -index - 1, newRootFileId);
        rootUrls = ArrayUtil.insert(rootUrls, -index - 1, rootUrlId);

        saveNameIdSequenceWithDeltas(rootUrls, rootIds, output);
        //RC: we should assign connection.records.setNameId(newRootFileId, root_Name_Id), but we don't
        //    have rootNameId here -- we have only rootUrlId. Actually, rootNameId is assigned to the root
        //    in a PersistentFSImpl.findRoot() method
        return newRootFileId;
      }
    }
    finally {
      rootsAccessLock.unlock();
    }
  }
int findOrCreateRootRecord(@NotNull String rootUrl)