{"record":{"id":"8b0aed6ccad3b4fd","repo":"apache/iceberg","slug":"failed-to-serialize-pk-index-key-8b0aed","errorCode":null,"errorMessage":"Failed to serialize PK index key","messagePattern":"Failed to serialize PK index key","errorType":"exception","errorClass":"UncheckedIOException","httpStatus":null,"severity":"error","filePath":"flink/v2.2/flink/src/main/java/org/apache/iceberg/flink/maintenance/operator/StructLikeSerializer.java","lineNumber":68,"sourceCode":"  private final ByteArrayOutputStream baos = new ByteArrayOutputStream();\n  private final DataOutputStream dos = new DataOutputStream(baos);\n\n  public SerializedEqualityValues serializeKey(StructLike key, Types.StructType keyType) {\n    baos.reset();\n    try {\n      List<Types.NestedField> fields = keyType.fields();\n      dos.writeInt(fields.size());\n      for (Types.NestedField field : fields) {\n        dos.writeInt(field.fieldId());\n      }\n\n      for (int i = 0; i < fields.size(); i++) {\n        writeField(key, i, fields.get(i).type());\n      }\n\n      dos.flush();\n    } catch (IOException e) {\n      throw new UncheckedIOException(\"Failed to serialize PK index key\", e);\n    }\n\n    return new SerializedEqualityValues(baos.toByteArray());\n  }\n\n  public byte[] encodePartition(StructLike partition, Types.StructType partitionType) {\n    List<Types.NestedField> fields = partitionType.fields();\n    if (fields.isEmpty()) {\n      return EMPTY_PARTITION;\n    }\n\n    baos.reset();\n    try {\n      for (int i = 0; i < fields.size(); i++) {\n        writeField(partition, i, fields.get(i).type());\n      }\n\n      dos.flush();","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/flink/v2.2/flink/src/main/java/org/apache/iceberg/flink/maintenance/operator/StructLikeSerializer.java#L50-L86","documentation":"StructLikeSerializer.serializeKey writes each primary-key field of a StructLike key into a DataOutputStream; IOExceptions from the underlying stream are rethrown as UncheckedIOException with this message. In practice this only happens on stream/IO failure since the stream is in-memory, but it signals the PK index key could not be encoded.","triggerScenarios":"An IOException while writing PK struct fields to the ByteArrayOutputStream-backed DataOutputStream inside serializeKey during delete-file index construction.","commonSituations":"Rare; usually indicates a JVM-level IO problem or memory pressure while buffering; may surface as a wrapped failure during maintenance table changes processing.","solutions":["Retry the maintenance job — in-memory serialization failures are typically transient.","Inspect the wrapped IOException cause for the root problem (e.g. OOM-related stream closure).","If reproducible, report an issue with the schema/types of the PK fields involved."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  key = serializer.serializeKey(pkStruct);\n} catch (UncheckedIOException e) {\n  LOG.error(\"PK key serialization failed\", e.getCause());\n  throw e;\n}","preventionTips":["Monitor task managers for OOM/IO issues that underlie serialization failures.","Report reproducible failures with the PK schema to the Iceberg project."],"tags":["flink","serialization","unchecked-io"],"backgroundTag":"json-serialization-failed","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}