apache/flink · error · EOFException

Could not skip {} bytes.

Error message

Could not skip {} bytes.

What it means

Thrown by skipBytesToWrite(int numBytes), a splicing helper on Record's serialization views. It first calls skipBytes(numBytes) on the input view, which returns how many bytes were actually skipped; because the view is bounded by this.end, a request that runs past the end of the record's memory returns fewer bytes than asked, and the mismatch is reported as an EOFException.

Source

Thrown at flink-core/src/main/java/org/apache/flink/types/Record.java:1836

                        "Serialization failed because the record length would exceed 2GB.");
            }
        }

        @SuppressWarnings("restriction")
        private static final sun.misc.Unsafe UNSAFE = MemoryUtils.UNSAFE;

        @SuppressWarnings("restriction")
        private static final long BASE_OFFSET = UNSAFE.arrayBaseOffset(byte[].class);

        private static final boolean LITTLE_ENDIAN =
                (MemoryUtils.NATIVE_BYTE_ORDER == ByteOrder.LITTLE_ENDIAN);

        @Override
        public void skipBytesToWrite(int numBytes) throws IOException {
            int skippedBytes = skipBytes(numBytes);

            if (skippedBytes != numBytes) {
                throw new EOFException("Could not skip " + numBytes + " bytes.");
            }
        }

        @Override
        public void write(DataInputView source, int numBytes) throws IOException {
            if (numBytes > this.end - this.position) {
                throw new IOException(
                        "Could not write " + numBytes + " bytes since the buffer is full.");
            }

            source.readFully(this.memory, this.position, numBytes);
            this.position += numBytes;
        }
    }
}

View on GitHub (pinned to 2f3c205e92)

Solutions

  1. Verify the remaining bytes: skip only Math.min(numBytes, availableBytes) where availableBytes = end - position
  2. Check that the field length you computed matches what was written (same writer schema/version on both sides)
  3. If records may be truncated, guard the splice path with a bounds check and reject the record explicitly

Example fix

// before
input.skipBytesToWrite(fieldLen); // may hit end of view

// after
int remaining = end - position; // or expose available()
input.skipBytesToWrite(Math.min(fieldLen, remaining));
Defensive patterns

Strategy: validation

Validate before calling

int available = end - position; // expose or compute remaining bytes in the view
input.skipBytesToWrite(Math.min(numBytes, available));

Try / catch

catch (EOFException e) { // record truncated: reject and skip to next }

Prevention

When it happens

Trigger: Calling skipBytesToWrite(n) on a deserialization input view where fewer than n bytes remain between the current position and this.end; typically during copy/splice operations between Record views that assume a fixed field width (e.g. skipping a variable-length field using a stale length).

Common situations: Copying data between Records with mismatched schemas or versions; a length-prefixed field whose declared length is larger than the actual serialized content; truncation/corruption of a record's binary buffer.

Related errors


AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14). Data as JSON: /api/errors/e2b59d6164bd77a5. Report an issue: GitHub.