{"record":{"id":"4b836d7f93f5c9cd","repo":"apache/iceberg","slug":"metastore-operation-failed-for-s-s","errorCode":null,"errorMessage":"Metastore operation failed for %s.%s","messagePattern":"Metastore operation failed for (.+?)\\.(.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"hive-metastore/src/main/java/org/apache/iceberg/hive/HiveTableOperations.java","lineNumber":415,"sourceCode":"          LOG.error(\n              \"Cannot tell if commit to {}.{} succeeded, attempting to reconnect and check.\",\n              database,\n              tableName,\n              e);\n          commitStatus = checkCommitStatus(newMetadataLocation, tableMetadata);\n        }\n\n        switch (commitStatus) {\n          case SUCCESS:\n            break;\n          case FAILURE:\n            throw e;\n          case UNKNOWN:\n            throw new CommitStateUnknownException(e);\n        }\n      }\n    } catch (TException e) {\n      throw new RuntimeException(\n          String.format(\"Metastore operation failed for %s.%s\", database, tableName), e);\n\n    } catch (InterruptedException e) {\n      Thread.currentThread().interrupt();\n      throw new RuntimeException(\"Interrupted during commit\", e);\n\n    } catch (LockException e) {\n      throw new CommitFailedException(e);\n\n    } finally {\n      HiveOperationsBase.cleanupMetadataAndUnlock(io(), commitStatus, newMetadataLocation, lock);\n    }\n\n    LOG.info(\n        \"Committed to table {} with the new metadata location {}\", fullName, newMetadataLocation);\n  }\n\n  @Override","sourceCodeStart":397,"sourceCodeEnd":433,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/hive-metastore/src/main/java/org/apache/iceberg/hive/HiveTableOperations.java#L397-L433","documentation":"Any Thrift exception (TException) propagating out of the HMS persistTable call — and not matching the more specific handlers — is wrapped in a RuntimeException 'Metastore operation failed for <db>.<table>'. It signals the HMS RPC itself failed (connection problem, protocol mismatch, server error) without a more precise classification.","triggerScenarios":"doCommit calling persistTable/alterTable when the metastore client throws TException: HMS unreachable, connection closed mid-call, Thrift protocol/version mismatch, or generic server-side MetaException.","commonSituations":"HMS down or restarted during commit; network partition between client and metastore; incompatible hive-metastore client vs server versions; metastore timeouts.","solutions":["Check HMS availability and connectivity (hive.metastore.uris, network, metastore logs)","Fix the underlying TException cause — inspect the wrapped cause chain","Retry the commit; if state is unknown, verify metadata_location in HMS first","Align client/server Thrift and Hive versions"],"exampleFix":"// before\nconf.set(\"hive.metastore.uris\", \"\"); // local embedded, may lack txn/lock support\n// after\nconf.set(\"hive.metastore.uris\", \"thrift://hms-host:9083\");\nconf.set(\"hive.metastore.client.connect.retry.attempts\", \"5\");","handlingStrategy":"retry","validationCode":"// pre-check HMS reachability\nHiveConf hc = new HiveConf();\nnew MetaStoreClientFactory(). // or a lightweight thrift ping to hive.metastore.uris before committing","typeGuard":null,"tryCatchPattern":"try {\n  table.newAppend().appendFile(f).commit();\n} catch (RuntimeException e) {\n  if (e.getCause() instanceof TException) {\n    // check HMS state: metadata_location may or may not have advanced\n    verifyCommitStateThenRetry();\n  } else throw e;\n}","preventionTips":["Monitor HMS uptime and network paths","Configure metastore client retries (hive.metastore.client.connect.retry.attempts)","Keep Hive client version compatible with the server","Treat commits after metastore RPC failures as state-unknown and verify first"],"tags":["hive-metastore","thrift","metastore-unavailable","rpc"],"backgroundTag":"network-request-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"}