{"record":{"id":"13eca403900c449c","repo":"apache/hadoop","slug":"unknown-flags-set-in-modifycachedirectiveinfoop","errorCode":null,"errorMessage":"unknown flags set in ModifyCacheDirectiveInfoOp: {}","messagePattern":"unknown flags set in ModifyCacheDirectiveInfoOp: (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageSerialization.java","lineNumber":565,"sourceCode":"    CacheDirectiveInfo.Builder builder =\n        new CacheDirectiveInfo.Builder();\n    builder.setId(readLong(in));\n    int flags = in.readInt();\n    if ((flags & 0x1) != 0) {\n      builder.setPath(new Path(readString(in)));\n    }\n    if ((flags & 0x2) != 0) {\n      builder.setReplication(readShort(in));\n    }\n    if ((flags & 0x4) != 0) {\n      builder.setPool(readString(in));\n    }\n    if ((flags & 0x8) != 0) {\n      builder.setExpiration(\n          CacheDirectiveInfo.Expiration.newAbsolute(readLong(in)));\n    }\n    if ((flags & ~0xF) != 0) {\n      throw new IOException(\"unknown flags set in \" +\n          \"ModifyCacheDirectiveInfoOp: \" + flags);\n    }\n    return builder.build();\n  }\n\n  public static CacheDirectiveInfo readCacheDirectiveInfo(Stanza st)\n      throws InvalidXmlException {\n    CacheDirectiveInfo.Builder builder =\n        new CacheDirectiveInfo.Builder();\n    builder.setId(Long.parseLong(st.getValue(\"ID\")));\n    String path = st.getValueOrNull(\"PATH\");\n    if (path != null) {\n      builder.setPath(new Path(path));\n    }\n    String replicationString = st.getValueOrNull(\"REPLICATION\");\n    if (replicationString != null) {\n      builder.setReplication(Short.parseShort(replicationString));\n    }","sourceCodeStart":547,"sourceCodeEnd":583,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageSerialization.java#L547-L583","documentation":"Cache-directive modify operations are serialized with a 4-bit flag word (0x1 id, 0x2 replication, 0x4 pool, 0x8 expiration). While deserializing a ModifyCacheDirectiveInfoOp, any set bit outside the 0xF mask is rejected: the stream contains fields this build does not understand. The edits were written by a newer release that defined an extra flag, or the data was hand-crafted.","triggerScenarios":"Reading edits or OEV XML containing a ModifyCacheDirectiveInfoOp with (flags & ~0xF) != 0 — e.g. replaying an edits file produced by a newer Hadoop release, or loading hand-edited OfflineEditsViewer output.","commonSituations":"Downgrade while cache-directive edits from a newer release are still in the journal; hand-edited OEV XML round-trips; copying edits across clusters of different versions.","solutions":["Replay the edits with the same or newer Hadoop release that wrote them","Do not hand-edit OEV XML; regenerate from the original binary edits","If version skew is from a rolling upgrade, finish it so all NNs run the writer's version or later","Convert the edits to a loadable form using the newer version's tooling before loading"],"exampleFix":"# before: old build rejects newer edits\nhdfs oev -i edits_0000000000000001000-0000000000000001500 -p xml -o e.xml\n# after: use the writer's release (or newer) to read/convert\n/opt/hadoop-3.3.6/bin/hdfs oev -i edits_0000000000000001000-0000000000000001500 -p xml -o e.xml","handlingStrategy":"validation","validationCode":"// reject edits written by a newer layout before replay\nNameNodeLayoutVersion_current = HdfsServerConstants.NAMENODE_LAYOUT_VERSION;\nif (editsLayoutVersion < HdfsServerConstants.NAMENODE_LAYOUT_VERSION) {\n  throw new IOException(\"edits layout \" + editsLayoutVersion\n      + \" newer than this build supports\");\n}","typeGuard":null,"tryCatchPattern":"catch IOException with 'unknown flags set in ModifyCacheDirectiveInfoOp' during edits replay — abort replay of that file and load it with the writer's Hadoop version instead of skipping records silently.","preventionTips":["Replay journals only on binaries at least as new as the writer","Never hand-edit OfflineEditsViewer XML","During rolling upgrades, let journal segments from old versions roll off before downgrading anything"],"tags":["hadoop","hdfs","namenode","cache-directive","edits","serialization","version-mismatch"],"backgroundTag":"file-format-version-mismatch","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}