Details
-
Bug
-
Resolution: Done
-
Blocker
-
1.3.0.Final
-
None
-
False
-
False
-
Undefined
-
Description
I'm trying Oracle Connector with logminer and found partition tables' redolog is never read by the engine while non-partition tables appears normally.
After debugging I found the sql for searching the redo-sql is like below:
SELECT SCN, SQL_REDO, OPERATION_CODE, TIMESTAMP, XID, CSF, TABLE_NAME, SEG_NAME, SEG_OWNER, OPERATION, USERNAME FROM V$LOGMNR_CONTENTS WHERE OPERATION_CODE in (1, 2, 3, 5) AND SEG_OWNER = 'U_REPORT' AND table_name IN ('CDC_TABLE') AND SCN >= ? AND SCN < ? ---- Notice this clause AND SEG_NAME IN ('CDC_TABLE') ---- OR (OPERATION_CODE IN (5, 7, 34, 36) AND USERNAME NOT IN ('SYS', 'SYSTEM', 'LOGMINER')) ORDER BY SCN
Notice the 'SEG_NAME IN' clause, it's produced by the below code:
// io.debezium.connector.oracle.logminer.SqlUtils private static String buildTableInPredicate(List<String> tables) { if (tables.size() == 0 || tables.size() > 1000) { LOGGER.warn(" Cannot apply {} whitelisted tables condition", tables.size()); return ""; } StringJoiner tableNames = new StringJoiner(","); tables.forEach(table -> tableNames.add("'" + table + "'")); return " AND table_name IN (" + tableNames + ") AND SEG_NAME IN (" + tableNames + ") "; }
In this code, the SEG_NAME is always set to equal tableName, it's OK when the table is non-partition, but a partition tables' SEG_NAME is like 'tableName'.'partitionName' and will never meet this condition. This is the reason for my issue.
I talked with my DBA and he think the 'SEG_NAME' condition may be unnecessary. So I delete the condition and it can run on partition table for me and I‘v created a [PR|https://github.com/debezium/debezium-incubator/pull/205]. But I'm still wondering your concern about adding this clause.