alibaba/canal · error · RuntimeException

apply to memory is failed

Error message

apply to memory is failed

What it means

Thrown by DatabaseTableMeta.apply() when the underlying memoryTableMeta.apply() returns false, indicating the DDL could not be applied to the in-memory schema representation. This blocks further DDL history persistence since the memory state is inconsistent.

Source

Thrown at parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/tsdb/DatabaseTableMeta.java:293

        try {
            return memoryTableMeta.find(schema, table);
        } finally {
            lock.readLock().unlock();
        }
    }

    @Override
    public boolean apply(EntryPosition position, String schema, String ddl, String extra) {
        // 首先记录到内存结构
        lock.writeLock().lock();
        try {
            if (memoryTableMeta.apply(position, schema, ddl, extra)) {
                this.lastPosition = position;
                this.hasNewDdl = true;
                // 同步每次变更给远程做历史记录
                return applyHistoryToDB(position, schema, ddl, extra);
            } else {
                throw new RuntimeException("apply to memory is failed");
            }
        } finally {
            lock.writeLock().unlock();
        }
    }

    @Override
    public boolean rollback(EntryPosition position) {
        // 每次rollback需要重新构建一次memory data
        // FIXME The global MemoryTableMeta may cause OOM when it store too many tables
        this.memoryTableMeta = new MemoryTableMeta();
        boolean flag = false;
        EntryPosition snapshotPosition = buildMemFromSnapshot(position);
        if (snapshotPosition != null) {
            applyHistoryOnMemory(snapshotPosition, position);
            flag = true;
        }

View on GitHub (pinned to 87be50e876)

Solutions

  1. Check the canal log for the specific DDL statement that caused memoryTableMeta.apply() to return false.
  2. If the DDL uses unsupported syntax, add the table to the canal block filter (canal.instance.filter.black.regex).
  3. Upgrade the Druid dependency to a version that supports the DDL syntax in use.
  4. If the DDL is from a non-critical table, exclude it from DDL tracking.
Defensive patterns

Strategy: try-catch

Try / catch

try {
    tableMeta.apply(position, schema, ddl, extra);
} catch (RuntimeException e) {
    if (e.getMessage().equals("apply to memory is failed")) {
        logger.warn("DDL could not be applied to memory, skipping: " + ddl);
        // optionally add table to blacklist filter
    } else {
        throw e;
    }
}

Prevention

When it happens

Trigger: memoryTableMeta.apply() returns false when the Druid DDL parser fails to parse or apply the DDL statement to the in-memory schema repository. This can happen with unsupported DDL syntax, DDL referencing non-existent objects, or parser bugs with complex statements.

Common situations: Unsupported MySQL DDL syntax (e.g., PARTITION, generated columns, spatial indexes); DDL for tables filtered out by canal configuration; Druid parser version incompatible with the MySQL version's DDL features; corrupt or truncated DDL text from binlog.

Related errors


AI-assisted analysis of alibaba/canal@87be50e876 (2026-08-14). Data as JSON: /api/errors/0bf781b5402dd4fa. Report an issue: GitHub.