prestodb/presto · error · PrestoException

INVALID_ARGUMENTS

INVALID_ARGUMENTS

Error message

Can not serialize remote split

What it means

RemoteSplitCodec.serialize converts a ConnectorSplit (cast to RemoteSplit) into a Thrift byte array for shipping to remote worker tasks. If the underlying Thrift encoding raises TProtocolException (e.g. a field value violates the Thrift protocol constraints), the codec wraps it in a PrestoException with code INVALID_ARGUMENTS, since a split that cannot be encoded is by definition malformed input.

Source

Thrown at presto-main-base/src/main/java/com/facebook/presto/thrift/RemoteSplitCodec.java:46

public class RemoteSplitCodec
        implements ConnectorCodec<ConnectorSplit>
{
    private final Provider<ThriftCodecManager> thriftCodecManagerProvider;

    public RemoteSplitCodec(Provider<ThriftCodecManager> thriftCodecManagerProvider)
    {
        this.thriftCodecManagerProvider = requireNonNull(thriftCodecManagerProvider, "thriftCodecManagerProvider is null");
    }

    @Override
    public byte[] serialize(ConnectorSplit split)
    {
        try {
            return toThrift((RemoteSplit) split, thriftCodecManagerProvider.get().getCodec(RemoteSplit.class));
        }
        catch (TProtocolException e) {
            throw new PrestoException(INVALID_ARGUMENTS, "Can not serialize remote split", e);
        }
    }

    @Override
    public ConnectorSplit deserialize(byte[] bytes)
    {
        try {
            return fromThrift(bytes, thriftCodecManagerProvider.get().getCodec(RemoteSplit.class));
        }
        catch (TProtocolException e) {
            throw new PrestoException(INVALID_ARGUMENTS, "Can not deserialize remote split", e);
        }
    }
}

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Inspect the wrapped TProtocolException cause to identify which RemoteSplit field fails Thrift encoding
  2. Verify the RemoteSplit was constructed with valid, Thrift-encodable fields (e.g. the serialized split bytes are well-formed)
  3. Confirm the Thrift codec manager resolves the same RemoteSplit codec version across all nodes
  4. Log the offending split's address/fields, drop or re-generate the split rather than retrying serialization

Example fix

// before
return toThrift((RemoteSplit) split, thriftCodecManagerProvider.get().getCodec(RemoteSplit.class));
// after
if (!(split instanceof RemoteSplit)) {
    throw new PrestoException(INVALID_ARGUMENTS, "Expected RemoteSplit, got " + split.getClass().getSimpleName());
}
RemoteSplit remoteSplit = (RemoteSplit) split;
return toThrift(remoteSplit, thriftCodecManagerProvider.get().getCodec(RemoteSplit.class));
Defensive patterns

Strategy: validation

Validate before calling

if (!(split instanceof RemoteSplit)) {
    throw new PrestoException(INVALID_ARGUMENTS, "serialize expects RemoteSplit, got " + split.getClass().getName());
}

Type guard

boolean isEncodableRemoteSplit(ConnectorSplit split) {
    return split instanceof RemoteSplit;
}

Try / catch

try {
    byte[] bytes = codec.serialize(split);
} catch (PrestoException e) {
    if (INVALID_ARGUMENTS.equals(e.getErrorCode())) {
        LOG.error(e, "Dropping unserializable remote split");
        return; // do not retry; the split payload is malformed
    }
    throw e;
}

Prevention

When it happens

Trigger: Calling serialize() with a ConnectorSplit that is not an instance of RemoteSplit (ClassCastException is not caught, but any TProtocolException raised by toThrift while encoding a RemoteSplit's fields triggers this).

Common situations: A RemoteSplit whose embedded byte payload or fields are corrupted or incompatible with the registered Thrift codec; mismatched Thrift library versions between coordinator and workers producing unencodable structures.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/f541494dffb269d2. Report an issue: GitHub.