{"record":{"id":"d55d7749a60c60c7","repo":"apache/iceberg","slug":"failed-reading-offset-from-s-d55d77","errorCode":null,"errorMessage":"Failed reading offset from: %s","messagePattern":"Failed reading offset from: (.+?)","errorType":"exception","errorClass":"UncheckedIOException","httpStatus":null,"severity":"critical","filePath":"spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/source/SparkMicroBatchStream.java","lineNumber":312,"sourceCode":"    }\n\n    private void writeOffset(StreamingOffset offset, OutputFile file) {\n      try (OutputStream outputStream = file.create()) {\n        BufferedWriter writer =\n            new BufferedWriter(new OutputStreamWriter(outputStream, StandardCharsets.UTF_8));\n        writer.write(offset.json());\n        writer.flush();\n      } catch (IOException ioException) {\n        throw new UncheckedIOException(\n            String.format(\"Failed writing offset to: %s\", initialOffsetLocation), ioException);\n      }\n    }\n\n    private StreamingOffset readOffset(InputFile file) {\n      try (InputStream in = file.newStream()) {\n        return StreamingOffset.fromJson(in);\n      } catch (IOException ioException) {\n        throw new UncheckedIOException(\n            String.format(\"Failed reading offset from: %s\", initialOffsetLocation), ioException);\n      }\n    }\n  }\n}\n","sourceCodeStart":294,"sourceCodeEnd":318,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/source/SparkMicroBatchStream.java#L294-L318","documentation":"Wrapping error in SparkMicroBatchStream.readOffset: reading the JSON-serialized StreamingOffset back from the checkpoint location failed with an IOException, rethrown as UncheckedIOException naming the source file (%s). Typically a missing/truncated offset file or storage read failure.","triggerScenarios":"The offset InputFile exists but newStream() or StreamingOffset.fromJson fails — truncated/corrupt offset file, storage errors, or the file vanished mid-read.","commonSituations":"Corrupted checkpoint offsets after failed writes; concurrent modification of the checkpoint location; object-store eventual consistency or deleted offset files.","solutions":["Inspect caused-by for the actual IO/parse error","Restore or clear the corrupt offset file and restart the stream from a fresh checkpoint","Verify checkpoint location integrity and credentials","Recreate the streaming query checkpoint if the offset is unrecoverable"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// before reading, verify offset file exists and is non-empty\nif (file == null || file.getLength() == 0) { /* reset to initial offset */ }","typeGuard":null,"tryCatchPattern":"try { offset = stream.readOffset(file); } catch (UncheckedIOException e) { /* fall back to initial offset or restore checkpoint from backup */ }","preventionTips":["Never delete or mutate the checkpoint offset file while the stream runs","Back up checkpoint directories","Use strongly consistent storage for checkpoints"],"tags":["spark","streaming","io-exception","checkpoint"],"backgroundTag":"file-read-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"}