@Override
  public void deleteRecord(final int recordId) throws IOException {
    checkRecordIdExists(recordId);

    final long recordOffset = idToOffset(recordId);
    try (final PageUnsafe page = (PageUnsafe)pagedStorage.pageByOffset(recordOffset, /*forWrite: */ true)) {
      final int offsetOnPage = pagedStorage.toOffsetInPage(recordOffset);
      page.lockPageForWrite();
      try {
        final ByteBuffer buffer = page.rawPageBuffer();
        final RecordLayout recordLayout = RecordLayout.recordLayout(buffer, offsetOnPage);
        final int recordCapacity = recordLayout.capacity(buffer, offsetOnPage);
        final int recordActualLength = recordLayout.length(buffer, offsetOnPage);
        final byte recordType = recordLayout.recordType();
        switch (recordType) {
          case RecordLayout.RECORD_TYPE_MOVED -> {
            final int redirectToId = recordLayout.redirectToId(buffer, offsetOnPage);
            if (!isValidRecordId(redirectToId)) {
              throw new RecordAlreadyDeletedException("Can't delete record[" + recordId + "]: it was already deleted");
            }

            // (redirectToId=NULL) <=> 'record deleted' ('moved nowhere')
            ((RecordLayout.MovedRecord)recordLayout).putRedirectTo(buffer, offsetOnPage, NULL_ID);
            page.regionModified(offsetOnPage, recordLayout.headerSize());
          }
          case RecordLayout.RECORD_TYPE_ACTUAL -> {
            final RecordLayout.MovedRecord movedRecordLayout = RecordLayout.MovedRecord.INSTANCE;
            //Total space occupied by record must remain constant, but record capacity should be
            // changed since MovedRecord has another headerSize than Small|LargeRecord
            final int deletedRecordCapacity = recordLayout.fullRecordSize(recordCapacity) - movedRecordLayout.headerSize();
            // set (redirectToId=NULL) to mark record as deleted ('moved nowhere')
            movedRecordLayout.putRecord(buffer, offsetOnPage, deletedRecordCapacity, 0, NULL_ID, null);
            page.regionModified(offsetOnPage, movedRecordLayout.headerSize());
          }
          default -> throw new AssertionError("RecordType(" + recordType + ") should not appear in the chain: " +
                                              "it is either not implemented yet, or all wrong");
        }

        recordsDeleted.incrementAndGet();
        totalLiveRecordsPayloadBytes.addAndGet(-recordActualLength);
        totalLiveRecordsCapacityBytes.addAndGet(-recordCapacity);
      }
      finally {
        page.unlockPageForWrite();
      }
    }
  }
@Override
  public void deleteRecord(final int recordId)