汇合jdbc源连接在转换中提供nullpointerexception

wyyhbhjk  于 2021-06-06  发布在  Kafka
关注(0)|答案(1)|浏览(269)

这真的很奇怪。在我的数据库中,当我执行以下sql时: select count(*) from mySchema.myTable where some_col = '2' 结果是:26000000
当连接器配置中的查询设置为此时,我运行连接器:

QUERY="select * from mySchema.myTable where some_col = '2' order by primary_key, sec_key limit 26000000"

连接器的工作没有问题,我能够消费所有的消息。
但是,当connector config中的查询设置为此时,我运行连接器:

QUERY="select * from mySchema.myTable where some_col = '2' order by primary_key, sec_key"

连接器给了我这个例外:

[2019-12-23 22:51:16,671] ERROR WorkerSourceTask{id=HIVE_JDBC_BATCH_SOURCE-0} Task threw an uncaught and unrecoverable exception (org.apache.kafka.connect.runtime.WorkerTask:177)
org.apache.kafka.connect.errors.ConnectException: Tolerance exceeded in error handler
                at org.apache.kafka.connect.runtime.errors.RetryWithToleranceOperator.execAndHandleError(RetryWithToleranceOperator.java:178)
                at org.apache.kafka.connect.runtime.errors.RetryWithToleranceOperator.execute(RetryWithToleranceOperator.java:104)
                at org.apache.kafka.connect.runtime.TransformationChain.apply(TransformationChain.java:50)
                at org.apache.kafka.connect.runtime.WorkerSourceTask.sendRecords(WorkerSourceTask.java:293)
                at org.apache.kafka.connect.runtime.WorkerSourceTask.execute(WorkerSourceTask.java:229)
                at org.apache.kafka.connect.runtime.WorkerTask.doRun(WorkerTask.java:175)
                at org.apache.kafka.connect.runtime.WorkerTask.run(WorkerTask.java:219)
                at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
                at java.util.concurrent.FutureTask.run(FutureTask.java:266)
                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
                at java.lang.Thread.run(Thread.java:748)

Caused by: java.lang.NullPointerException
                at org.apache.kafka.connect.transforms.ValueToKey.applyWithSchema(ValueToKey.java:85)
                at org.apache.kafka.connect.transforms.ValueToKey.apply(ValueToKey.java:65)
                at org.apache.kafka.connect.runtime.TransformationChain.lambda$apply$0(TransformationChain.java:50)
                at org.apache.kafka.connect.runtime.errors.RetryWithToleranceOperator.execAndRetry(RetryWithToleranceOperator.java:128)
                at org.apache.kafka.connect.runtime.errors.RetryWithToleranceOperator.execAndHandleError(RetryWithToleranceOperator.java:162)
                ... 11 more

以下是配置:
[2019-12-23 22:51:00681]信息连接器配置值:

config.action.reload = restart
    connector.class = io.confluent.connect.jdbc.JdbcSourceConnector
    errors.log.enable = false
    errors.log.include.messages = false
    errors.retry.delay.max.ms = 60000
    errors.retry.timeout = 0
    errors.tolerance = none
    header.converter = null
    key.converter = class org.apache.kafka.connect.storage.StringConverter
    name = HIVE_JDBC_BATCH_SOURCE
    tasks.max = 8
    transforms = [createKey, extractString]
    value.converter = class org.apache.kafka.connect.json.JsonConverter

[2019-12-23 22:51:00681]信息丰富的连接器配置值:

config.action.reload = restart
    connector.class = io.confluent.connect.jdbc.JdbcSourceConnector
    errors.log.enable = false
    errors.log.include.messages = false
    errors.retry.delay.max.ms = 60000
    errors.retry.timeout = 0
    errors.tolerance = none
    header.converter = null
    key.converter = class org.apache.kafka.connect.storage.StringConverter
    name = HIVE_JDBC_BATCH_SOURCE
    tasks.max = 8
    transforms = [createKey, extractString]
    transforms.createKey.fields = [mySchema.primary_key]
    transforms.createKey.type = class org.apache.kafka.connect.transforms.ValueToKey
    transforms.extractString.field = mySchema.primary_key
    transforms.extractString.type = class org.apache.kafka.connect.transforms.ExtractField$Key
    value.converter = class org.apache.kafka.connect.json.JsonConverter

[2019-12-23 22:51:00686]信息字符串转换器配置值:

converter.encoding = UTF8
    converter.type = key

[2019-12-23 22:51:00686]信息jsonconverterconfig值:

converter.type = value
    schemas.cache.size = 1000
    schemas.enable = false

[2019-12-23 22:51:00701]信息产品配置值:

acks = all
    batch.size = 100000
    bootstrap.servers = xxx
    buffer.memory = 33554432
    client.dns.lookup = default
    client.id = 
    compression.type = none
    connections.max.idle.ms = 540000
    delivery.timeout.ms = 2147483647
    enable.idempotence = false
    interceptor.classes = []
    key.serializer = class org.apache.kafka.common.serialization.ByteArraySerializer
    linger.ms = 10
    max.block.ms = 9223372036854775807
    max.in.flight.requests.per.connection = 1
    max.request.size = 10485760
    metadata.max.age.ms = 300000
    metric.reporters = []
    metrics.num.samples = 2
    metrics.recording.level = INFO
    metrics.sample.window.ms = 30000
    partitioner.class = class org.apache.kafka.clients.producer.internals.DefaultPartitioner
    receive.buffer.bytes = 32768
    reconnect.backoff.max.ms = 1000
    reconnect.backoff.ms = 50
    request.timeout.ms = 310000
    retries = 2147483647
    retry.backoff.ms = 100

[2019-12-23 22:51:00810]信息jdbcsourcetaskconfig值:

batch.max.rows = 100
    catalog.pattern = null
    connection.attempts = 5
    connection.backoff.ms = 60000
    connection.password = null
    connection.url = xxx
    connection.user = null
    db.timezone = UTC
    dialect.name = 
    incrementing.column.name = 
    mode = bulk
    numeric.mapping = null
    numeric.precision.mapping = false
    poll.interval.ms = 86400000
    query = select * from mySchema.myTable where some_col = '2' order by primary_key, sec_key
    quote.sql.identifiers = ALWAYS
    schema.pattern = mySchema
    table.blacklist = []
    table.poll.interval.ms = 60000
    table.types = [TABLE]
    table.whitelist = []
    tables = []
    timestamp.column.name = []
    timestamp.delay.interval.ms = 0
    topic.prefix = my_topic
    validate.non.null = false

db表中的示例数据:
主钥匙2c58131ff9680d5632cb1fdc27675490
备用钥匙3ee
第1年
201911年月
目录\u txt 2016-10-072016-10-12memorex1234500172409430291.52
连接器生成的示例消息:
{“myschema.primary\u key”:“2c58131ff9680d5632cb1fdc27675490”,“myschema.sec\u key”:“3ee”,“myschema.year\u cd”:“1”,“myschema.year\u month”:“201911”,“myschema.content\u txt”:“2016-10-072016-10-12memorex1234500172409430291.52”}

uidvcgyl

uidvcgyl1#

我找到了这个bug(imo,jdbcsourceconnector中的bug)
查询具有“limit子句”时连接器生成的示例消息:
{“myschema.primary\u key”:“2c58131ff9680d5632cb1fdc27675490”,“myschema.sec\u key”:“3ee”,“myschema.year\u cd”:“1”,“myschema.year\u month”:“201911”,“myschema.content\u txt”:“2016-10-072016-10-12memorex1234500172409430291.52”}
查询没有“limit子句”时连接器生成的示例消息:
{“主密钥”:“2c58131ff9680d5632cb1fdc27675490”,“辅密钥”:“3ee”,“年光盘”:“1”,“年月”:“201911”,“内容文本”:“2016-10-072016-10-12memorex1234500172409430291.52”}
当设置如下:transforms.extractstring.field=myschema.primary\u key时,连接器会引发nullpointerexception,因此我将设置更改为:transforms.extractstring.field=primary\u key,它就像一个符咒。

相关问题