{"record":{"id":"8f95e52ae0735ceb","repo":"prestodb/presto","slug":"not-found-8f95e5","errorCode":"NOT_FOUND","errorMessage":"Schema [%s] does not exist","messagePattern":"Schema \\[(.+?)\\] does not exist","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-memory/src/main/java/com/facebook/presto/plugin/memory/MemoryMetadata.java","lineNumber":122,"sourceCode":"    public synchronized List<String> listSchemaNames(ConnectorSession session)\n    {\n        return ImmutableList.copyOf(schemas);\n    }\n\n    @Override\n    public synchronized void createSchema(ConnectorSession session, String schemaName, Map<String, Object> properties)\n    {\n        if (schemas.contains(schemaName)) {\n            throw new PrestoException(ALREADY_EXISTS, format(\"Schema [%s] already exists\", schemaName));\n        }\n        schemas.add(schemaName);\n    }\n\n    @Override\n    public synchronized void dropSchema(ConnectorSession session, String schemaName)\n    {\n        if (!schemas.contains(schemaName)) {\n            throw new PrestoException(NOT_FOUND, format(\"Schema [%s] does not exist\", schemaName));\n        }\n\n        boolean tablesExist = tables.values().stream()\n                .anyMatch(table -> table.getSchemaName().equals(schemaName));\n\n        if (tablesExist) {\n            throw new PrestoException(SCHEMA_NOT_EMPTY, \"Schema not empty: \" + schemaName);\n        }\n\n        verify(schemas.remove(schemaName));\n    }\n\n    @Override\n    public synchronized ConnectorTableHandle getTableHandle(ConnectorSession session, SchemaTableName schemaTableName)\n    {\n        Long tableId = tableIds.get(schemaTableName);\n        if (tableId == null) {\n            return null;","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-memory/src/main/java/com/facebook/presto/plugin/memory/MemoryMetadata.java#L104-L140","documentation":"MemoryMetadata.dropSchema validates that the schema exists before removing it. If schemas.contains(schemaName) is false, it throws PrestoException NOT_FOUND saying the schema does not exist. Memory connector state is per-node/session-lifetime, so schemas vanish on restart, which frequently triggers this error.","triggerScenarios":"DROP SCHEMA memory.<name> for a schema never created, already dropped, or lost because the memory connector's in-memory state was reset (coordinator restart, different node).","commonSituations":"Cleanup scripts dropping schemas that were created in a previous server lifetime; running DROP on the wrong catalog (schema exists in another connector); distributed memory catalog where a worker restarted losing state.","solutions":["Use DROP SCHEMA IF EXISTS memory.<name>","Verify with SHOW SCHEMAS FROM memory that the schema currently exists","Recreate the schema and its data if memory state was lost on restart","Target the correct catalog where the schema actually lives"],"exampleFix":"// before\nDROP SCHEMA memory.test_schema;\n// after\nDROP SCHEMA IF EXISTS memory.test_schema;","handlingStrategy":"try-catch","validationCode":"// Only drop when schema currently exists\nif (metadata.listSchemaNames(session, \"memory\").contains(schemaName)) {\n    metadata.dropSchema(session, schemaName);\n}","typeGuard":null,"tryCatchPattern":"try {\n    metadata.dropSchema(session, schemaName);\n} catch (PrestoException e) {\n    if (NOT_FOUND.equals(e.getErrorCode())) {\n        log.info(\"Schema {} already gone, ignoring\", schemaName);\n    } else throw e;\n}","preventionTips":["Use DROP SCHEMA IF EXISTS","Remember memory-connector state is lost on restart","Verify the schema is in the catalog you are operating on","Make teardown scripts tolerant of missing objects"],"tags":["ddl","schema","not-found","memory-connector"],"backgroundTag":"resource-not-found","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}