开发者社区 问答 正文

canal1.1.4,es6子表不更新

联表查询,一对多关系(es->多mysql),主表的增删改都能生效,但是改子表无效,并且看debug发了个空doc过去。 yml配置如下, dataSourceKey: defaultDS destination: xxx groupId: g1 esMapping: _index: test _type: t_elasticsearch _id: _id upsert: true sql: "select e.id as _id,e.id,e.type,e.creat_time as creatTime ,email from t_elasticsearch e left join users u on u.e_id=e.id" etlCondition: "where a.c_time>={}" commitBatch: 3000

日志如下: 2019-10-21 17:19:24.984 [pool-3-thread-1] DEBUG c.a.o.canal.adapter.launcher.loader.CanalAdapterWorker - com.alibaba.otter.canal.client.adapter.logger.LoggerAdapterExample elapsed time: 0 2019-10-21 17:19:24.997 [pool-3-thread-1] DEBUG c.a.otter.canal.client.adapter.es.service.ESSyncService - DML: {"data":[{"e_id":"3","email":"@333","t1":"3","t2":"3"}],"database":"ttt","destination":"xxx","es":1571649564000,"groupId":null,"isDdl":false,"old":[{"email":"@3"}],"pkNames":["e_id"],"sql":"","table":"users","ts":1571649564985,"type":"UPDATE"} Affected indexes: test 2019-10-21 17:19:24.998 [pool-3-thread-1] DEBUG org.apache.http.impl.nio.client.MainClientExec - [exchange: 6] start execution 2019-10-21 17:19:24.998 [pool-3-thread-1] DEBUG org.apache.http.client.protocol.RequestAddCookies - CookieSpec selected: default 2019-10-21 17:19:24.998 [pool-3-thread-1] DEBUG org.apache.http.client.protocol.RequestAuthCache - Re-using cached 'basic' auth scheme for http://localhost:9200 2019-10-21 17:19:24.999 [pool-3-thread-1] DEBUG org.apache.http.client.protocol.RequestAuthCache - No credentials for preemptive authentication 2019-10-21 17:19:24.999 [pool-3-thread-1] DEBUG org.apache.http.impl.nio.client.InternalHttpAsyncClient - [exchange: 6] Request connection for {}->http://localhost:9200 2019-10-21 17:19:25.004 [pool-3-thread-1] DEBUG o.a.h.impl.nio.conn.PoolingNHttpClientConnectionManager - Connection request: [route: {}->http://localhost:9200][total kept alive: 1; route allocated: 1 of 10; total allocated: 1 of 30] 2019-10-21 17:19:25.004 [pool-3-thread-1] DEBUG o.a.http.impl.nio.conn.ManagedNHttpClientConnectionImpl - http-outgoing-0 127.0.0.1:49526<->127.0.0.1:9200[ACTIVE][r:r]: Set timeout 0 2019-10-21 17:19:25.005 [pool-3-thread-1] DEBUG o.a.h.impl.nio.conn.PoolingNHttpClientConnectionManager - Connection leased: [id: http-outgoing-0][route: {}->http://localhost:9200][total kept alive: 0; route allocated: 1 of 10; total allocated: 1 of 30] 2019-10-21 17:19:25.005 [pool-3-thread-1] DEBUG org.apache.http.impl.nio.client.InternalHttpAsyncClient - [exchange: 6] Connection allocated: CPoolProxy{http-outgoing-0 [ACTIVE]} 2019-10-21 17:19:25.005 [pool-3-thread-1] DEBUG o.a.http.impl.nio.conn.ManagedNHttpClientConnectionImpl - http-outgoing-0 127.0.0.1:49526<->127.0.0.1:9200[ACTIVE][r:r]: Set attribute http.nio.exchange-handler 2019-10-21 17:19:25.005 [I/O dispatcher 1] DEBUG org.apache.http.impl.nio.client.InternalIODispatch - http-outgoing-0 [ACTIVE] Request ready 2019-10-21 17:19:25.005 [pool-3-thread-1] DEBUG o.a.http.impl.nio.conn.ManagedNHttpClientConnectionImpl - http-outgoing-0 127.0.0.1:49526<->127.0.0.1:9200[ACTIVE][rw:w]: Event set [w] 2019-10-21 17:19:25.005 [I/O dispatcher 1] DEBUG org.apache.http.impl.nio.client.InternalHttpAsyncClient - Connection route already established 2019-10-21 17:19:25.005 [I/O dispatcher 1] DEBUG org.apache.http.impl.nio.client.MainClientExec - [exchange: 6] Attempt 1 to execute request 2019-10-21 17:19:25.006 [I/O dispatcher 1] DEBUG org.apache.http.impl.nio.client.MainClientExec - Target auth state: UNCHALLENGED 2019-10-21 17:19:25.006 [I/O dispatcher 1] DEBUG org.apache.http.impl.nio.client.MainClientExec - Proxy auth state: UNCHALLENGED 2019-10-21 17:19:25.006 [I/O dispatcher 1] DEBUG o.a.http.impl.nio.conn.ManagedNHttpClientConnectionImpl - http-outgoing-0 127.0.0.1:49526<->127.0.0.1:9200[ACTIVE][rw:w]: Set timeout 30000 2019-10-21 17:19:25.006 [I/O dispatcher 1] DEBUG org.apache.http.headers - http-outgoing-0 >> POST /_bulk?timeout=1m HTTP/1.1 2019-10-21 17:19:25.006 [I/O dispatcher 1] DEBUG org.apache.http.headers - http-outgoing-0 >> Content-Length: 97 2019-10-21 17:19:25.006 [I/O dispatcher 1] DEBUG org.apache.http.headers - http-outgoing-0 >> Content-Type: application/json 2019-10-21 17:19:25.006 [I/O dispatcher 1] DEBUG org.apache.http.headers - http-outgoing-0 >> Host: localhost:9200 2019-10-21 17:19:25.006 [I/O dispatcher 1] DEBUG org.apache.http.headers - http-outgoing-0 >> Connection: Keep-Alive 2019-10-21 17:19:25.006 [I/O dispatcher 1] DEBUG org.apache.http.headers - http-outgoing-0 >> User-Agent: Apache-HttpAsyncClient/4.1.2 (Java/1.8.0_181) 2019-10-21 17:19:25.006 [I/O dispatcher 1] DEBUG o.a.http.impl.nio.conn.ManagedNHttpClientConnectionImpl - http-outgoing-0 127.0.0.1:49526<->127.0.0.1:9200[ACTIVE][rw:w]: Event set [w] 2019-10-21 17:19:25.006 [I/O dispatcher 1] DEBUG org.apache.http.impl.nio.client.InternalIODispatch - http-outgoing-0 [ACTIVE] Output ready 2019-10-21 17:19:25.006 [I/O dispatcher 1] DEBUG org.apache.http.impl.nio.client.MainClientExec - [exchange: 6] produce content 2019-10-21 17:19:25.006 [I/O dispatcher 1] DEBUG org.apache.http.impl.nio.client.MainClientExec - [exchange: 6] Request completed 2019-10-21 17:19:25.006 [I/O dispatcher 1] DEBUG org.apache.http.impl.nio.client.InternalIODispatch - http-outgoing-0 [ACTIVE] [content length: 97; pos: 97; completed: true] 2019-10-21 17:19:25.013 [I/O dispatcher 1] DEBUG o.a.http.impl.nio.conn.ManagedNHttpClientConnectionImpl - http-outgoing-0 127.0.0.1:49526<->127.0.0.1:9200[ACTIVE][rw:w]: 289 bytes written 2019-10-21 17:19:25.014 [I/O dispatcher 1] DEBUG org.apache.http.wire - http-outgoing-0 >> "POST /_bulk?timeout=1m HTTP/1.1[\r][\n]" 2019-10-21 17:19:25.014 [I/O dispatcher 1] DEBUG org.apache.http.wire - http-outgoing-0 >> "Content-Length: 97[\r][\n]" 2019-10-21 17:19:25.014 [I/O dispatcher 1] DEBUG org.apache.http.wire - http-outgoing-0 >> "Content-Type: application/json[\r][\n]" 2019-10-21 17:19:25.014 [I/O dispatcher 1] DEBUG org.apache.http.wire - http-outgoing-0 >> "Host: localhost:9200[\r][\n]" 2019-10-21 17:19:25.014 [I/O dispatcher 1] DEBUG org.apache.http.wire - http-outgoing-0 >> "Connection: Keep-Alive[\r][\n]" 2019-10-21 17:19:25.014 [I/O dispatcher 1] DEBUG org.apache.http.wire - http-outgoing-0 >> "User-Agent: Apache-HttpAsyncClient/4.1.2 (Java/1.8.0_181)[\r][\n]" 2019-10-21 17:19:25.014 [I/O dispatcher 1] DEBUG org.apache.http.wire - http-outgoing-0 >> "[\r][\n]" 2019-10-21 17:19:25.014 [I/O dispatcher 1] DEBUG org.apache.http.wire - http-outgoing-0 >> "{"update":{"_index":"test","_type":"t_elasticsearch","_id":"3"}}[\n]" 2019-10-21 17:19:25.014 [I/O dispatcher 1] DEBUG org.apache.http.wire - http-outgoing-0 >> "{"doc_as_upsert":true,"doc":{}}[\n]" 2019-10-21 17:19:25.014 [I/O dispatcher 1] DEBUG org.apache.http.impl.nio.client.InternalIODispatch - http-outgoing-0 [ACTIVE] Request ready 2019-10-21 17:19:25.014 [I/O dispatcher 1] DEBUG o.a.http.impl.nio.conn.ManagedNHttpClientConnectionImpl - http-outgoing-0 127.0.0.1:49526<->127.0.0.1:9200[ACTIVE][r:w]: Event cleared [w] 2019-10-21 17:19:25.016 [I/O dispatcher 1] DEBUG o.a.http.impl.nio.conn.ManagedNHttpClientConnectionImpl - http-outgoing-0 127.0.0.1:49526<->127.0.0.1:9200[ACTIVE][r:r]: 277 bytes read 2019-10-21 17:19:25.016 [I/O dispatcher 1] DEBUG org.apache.http.wire - http-outgoing-0 << "HTTP/1.1 200 OK[\r][\n]" 2019-10-21 17:19:25.016 [I/O dispatcher 1] DEBUG org.apache.http.wire - http-outgoing-0 << "content-type: application/json; charset=UTF-8[\r][\n]" 2019-10-21 17:19:25.016 [I/O dispatcher 1] DEBUG org.apache.http.wire - http-outgoing-0 << "content-length: 190[\r][\n]" 2019-10-21 17:19:25.016 [I/O dispatcher 1] DEBUG org.apache.http.wire - http-outgoing-0 << "[\r][\n]" 2019-10-21 17:19:25.016 [I/O dispatcher 1] DEBUG org.apache.http.wire - http-outgoing-0 << "{"took":1,"errors":false,"items":[{"update":{"_index":"test","_type":"t_elasticsearch","_id":"3","_version":2,"result":"noop","_shards":{"total":2,"successful":1,"failed":0},"status":200}}]}" 2019-10-21 17:19:25.017 [I/O dispatcher 1] DEBUG org.apache.http.headers - http-outgoing-0 << HTTP/1.1 200 OK 2019-10-21 17:19:25.017 [I/O dispatcher 1] DEBUG org.apache.http.headers - http-outgoing-0 << content-type: application/json; charset=UTF-8 2019-10-21 17:19:25.017 [I/O dispatcher 1] DEBUG org.apache.http.headers - http-outgoing-0 << content-length: 190 2019-10-21 17:19:25.017 [I/O dispatcher 1] DEBUG org.apache.http.impl.nio.client.InternalIODispatch - http-outgoing-0 [ACTIVE(190)] Response received 2019-10-21 17:19:25.017 [I/O dispatcher 1] DEBUG org.apache.http.impl.nio.client.MainClientExec - [exchange: 6] Response received HTTP/1.1 200 OK 2019-10-21 17:19:25.017 [I/O dispatcher 1] DEBUG org.apache.http.impl.nio.client.InternalIODispatch - http-outgoing-0 [ACTIVE(190)] Input ready 2019-10-21 17:19:25.017 [I/O dispatcher 1] DEBUG org.apache.http.impl.nio.client.MainClientExec - [exchange: 6] Consume content 2019-10-21 17:19:25.017 [I/O dispatcher 1] DEBUG org.apache.http.impl.nio.client.InternalHttpAsyncClient - [exchange: 6] Connection can be kept alive indefinitely

==================================表结构 CREATE TABLE t_elasticsearch ( id varchar(25) NOT NULL, name varchar(255) DEFAULT NULL, type int(2) NOT NULL DEFAULT '0', creat_time datetime DEFAULT NULL, PRIMARY KEY (id), KEY type (type) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='测试elasticsearch ';

CREATE TABLE users ( e_id varchar(50) NOT NULL, email varchar(50) DEFAULT NULL, t1 varchar(255) DEFAULT NULL, t2 varchar(255) DEFAULT NULL, PRIMARY KEY (e_id) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

原提问者GitHub用户shinerdeng

展开
收起
Java工程师 2023-05-03 16:09:14 111 分享 版权
1 条回答
写回答
取消 提交回答
  • 看源码是找问题了,sql的字段要加表名,email from改成u.email from

    原回答者GitHub用户shinerdeng

    2023-05-04 17:58:42
    赞同 展开评论