Maxwell Couldn't find table xx in database xx
2025-12-13 15:03:21 1
开发环境的maxwell中间挂过一段时间, 再启动一直报这个错
java.lang.RuntimeException: Couldn't find table device_info_change_log_202512 in database mp-device
at com.zendesk.maxwell.replication.TableCache.processEvent(TableCache.java:31)
at com.zendesk.maxwell.replication.BinlogConnectorReplicator.getTransactionRows(BinlogConnectorReplicator.java:538)
at com.zendesk.maxwell.replication.BinlogConnectorReplicator.getRow(BinlogConnectorReplicator.java:662)
at com.zendesk.maxwell.replication.BinlogConnectorReplicator.work(BinlogConnectorReplicator.java:186)
at com.zendesk.maxwell.util.RunLoopProcess.runLoop(RunLoopProcess.java:34)
at com.zendesk.maxwell.Maxwell.startInner(Maxwell.java:256)
at com.zendesk.maxwell.Maxwell.start(Maxwell.java:183)
at com.zendesk.maxwell.Maxwell.main(Maxwell.java:287)报错是因为 com.zendesk.maxwell.schema.Database#tableList 内没有新表
tableList 又来源于 com.zendesk.maxwell.schema.MysqlSavedSchema#restoreFullSchema 的sql结果
String sql =
"SELECT " +
"d.id AS dbId," +
"d.name AS dbName," +
"d.charset AS dbCharset," +
"t.name AS tableName," +
"t.charset AS tableCharset," +
"t.pk AS tablePk," +
"t.id AS tableId," +
"c.column_length AS columnLength," +
"c.enum_values AS columnEnumValues," +
"c.name AS columnName," +
"c.charset AS columnCharset," +
"c.coltype AS columnColtype," +
"c.is_signed AS columnIsSigned " +
"FROM `databases` d " +
"LEFT JOIN tables t ON d.id = t.database_id " +
"LEFT JOIN columns c ON c.table_id=t.id " +
"WHERE d.schema_id = ? " +
"ORDER BY d.id, t.id, c.id";随后全局搜索 insert into `tables` , 找到了这个方法 com.zendesk.maxwell.schema.MysqlSavedSchema#saveFullSchema
调用栈往上
com.zendesk.maxwell.schema.MysqlSchemaStore#captureAndSaveSchema
MysqlSavedSchema savedSchema = new MysqlSavedSchema(serverID, caseSensitivity, captureSchema(), initialPosition);其中 captureSchema() 使用了这么一条sql SELECT SCHEMA_NAME, DEFAULT_CHARACTER_SET_NAME FROM INFORMATION_SCHEMA.SCHEMATA 查询最新的数据库表信息
由 com.zendesk.maxwell.schema.MysqlSchemaStore#captureAndSaveSchema 的调用栈再往上, 找到了这行 com.zendesk.maxwell.Maxwell#startInner
if (config.recaptureSchema) {
mysqlSchemaStore.captureAndSaveSchema();
}从文档找到这行说明
https://maxwells-daemon.io/config/#mysql
https://maxwells-daemon.io/apidocs/com/zendesk/maxwell/MaxwellConfig.html#recaptureSchema
| option | argument | description | default |
|---|---|---|---|
| recapture_schema | BOOLEAN | recapture the latest schema. Not available in config.properties. | false |
重新获取最新的 schema 在 config.properties 中不可用
我们在命令行启动时添加参数 --recapture_schema true
等待程序拉取最新 schema, 解决
maxwell 1.35.5




