apache/druid · error · RE

Exception encountered while serializing

Error message

Exception encountered while serializing [%s] in [%s]

What it means

FrameBasedInlineDataSourceSerializer serializes inline datasource rows into a frame. If an IOException occurs during serialization and it cannot be propagated normally, it is wrapped in this ResourceNoSuchEntity/RE (runtime exception) listing the offending row's elements. This indicates a row could not be written to the underlying frame/writer (e.g. closed or broken writer).

Solutions

  1. Inspect the row contents in the message and the wrapped cause to see why serialization failed (often a type or capacity mismatch).
  2. Retry the query/task — transient IO issues with the frame writer may resolve.
  3. Check column types in the inline datasource signature match the row values.
  4. If persistent, report/investigate; the code notes this path ideally shouldn't be reachable.
Defensive patterns

Strategy: try-catch

Try / catch

try {
  serializer.write(row);
} catch (RuntimeException e) {
  if (e.getMessage() != null && e.getMessage().startsWith("Exception encountered while serializing")) {
    // inspect row values and cause; retry task
  } else { throw e; }
}

Prevention

When it happens

Trigger: An IOException thrown by the underlying FrameWriter while serializing a row of a FrameBasedInlineDataSource (commonly used in MSQ/inline tables); the catch block converts it to this RuntimeException with the row contents in the message.

Common situations: MSQ tasks building inline tables whose frame writer has hit a capacity/IO failure; memory pressure causing writer failure mid-row; rows with values incompatible with the frame column types.

Understand the failure class

Background: "JSON serialization failed", "not JSON serializable", "Failed to serialize": why JSON marshaling errors happen and how to fix them — this error's family across 46 libraries.

Related errors


AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07). Data as JSON: /api/errors/6735744d93e9f63f. Report an issue: GitHub.

Appendix: source

Thrown at processing/src/main/java/org/apache/druid/query/FrameBasedInlineDataSourceSerializer.java:77

    List<ColumnType> columnTypes = IntStream.range(0, rowSignature.size())
                                            .mapToObj(i -> rowSignature.getColumnType(i).orElse(null))
                                            .collect(Collectors.toList());
    jg.writeObjectField("columnTypes", columnTypes);

    jg.writeArrayFieldStart("rows");

    value.getRowsAsSequence().forEach(row -> {
      try {
        JacksonUtils.writeObjectUsingSerializerProvider(jg, serializers, row);
      }
      catch (IOException e) {
        // Ideally, this shouldn't be reachable.
        // Wrap the IO exception in the runtime exception and propogate it forward
        List<String> elements = new ArrayList<>();
        for (Object o : row) {
          elements.add(o.toString());
        }
        throw new RE(
            e,
            "Exception encountered while serializing [%s] in [%s]",
            String.join(", ", elements),
            FrameBasedInlineDataSource.class
        );
      }
    });

    jg.writeEndArray();
    jg.writeEndObject();
  }

  /**
   * Required because {@link DataSource} is polymorphic
   */
  @Override
  public void serializeWithType(
      FrameBasedInlineDataSource value,

View on GitHub (pinned to 9b90983fd2)