Uploaded image for project: 'Debezium'
  1. Debezium
  2. DBZ-6347

Duplicate JMX MBean names when multiple vitess tasks running in the same JVM

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 2.2.0.Final
    • 2.1.4.Final
    • vitess-connector
    • None

    Description

      In order to make your issue reports as actionable as possible, please provide the following information, depending on the issue type.

      Bug report

      For bug reports, provide this information, please:

      What Debezium connector do you use and what version?

      Vitess

      What is the connector configuration?

      {

        *  {}"name"{}:{} "byuser-connector",{*}

        *  {}"config"{}: {{*}

          *    {}"connector.class"{}:{} "io.debezium.connector.vitess.VitessConnector",{*}

          *    {}"vitess.offset.storage.task.key.gen"{}:{} "1",{*}

          *    {}"database.user"{}:{} "${file:/etc/slack.d/vt_grpc_static_auth_client_creds.properties:username}",{*}

          *    {}"max.queue.size"{}:{} "16384",{*}

          *    {}"bigint.unsigned.handling.mode"{}:{} "long",{*}

          *    {}"tasks.max"{}:{} "2",{*}

          *    {}"vitess.keepalive.interval.ms"{}:{} "360000",{*}

          *    {}"database.port"{}:{} "15999",{*}

          *    {}"vitess.tablet.type"{}:{} "REPLICA",{*}

          *    {}"tombstones.on.delete"{}:{} "false",{*}

          *    {}"topic.prefix"{}:{} "dev.byuser",{*}

          *    {}"database.hostname"{}:{} "type-vcachesvc.vitess-vtgate.service.dev-us-east-1-vitess1.consul",{*}

          *    {}"database.password"{}:{} "${file:/etc/slack.d/vt_grpc_static_auth_client_creds.properties:password}",{*}

          *    {}"poll.interval.ms"{}:{} "1000",{*}

          *    {}"vitess.prev.num.tasks"{}:{} "1",{*}

          *    {}"name"{}:{} "byuser-connector",{*}

          *    {}"vitess.offset.storage.per.task"{}:{} "true",{*}

          *    {}"max.batch.size"{}:{} "1024",{*}

          *    {}"table.include.list"{}:{} "byuser.channels_members",{*}

          *    {}"topic.naming.strategy"{}:{} "io.debezium.schema.DefaultTopicNamingStrategy",{*}

          *    {}"vitess.keyspace"{}:{} "byuser",{*}

          *    {}"snapshot.mode"{}:{*} "never"

        },

        *  {}"tasks"{}: [{*}

          {

            *      {}"connector"{}:{} "byuser-connector",{*}

            *      {}"task"{}:{*} 0

          },

          {

            *      {}"connector"{}:{} "byuser-connector",{*}

            *      {}"task"{}:{*} 1

          }

        ],

        *  {}"type"{}:{*} "source"

      }

      What is the captured database version and mode of depoyment?

      (E.g. on-premises, with a specific cloud provider, etc.)

      Vitess 12

      What behaviour do you expect?

      Normal JMX Bean metrics reporting like the following:

      2023-04-11 04:52:29,452 INFO   Vitess|dev.byuser|snapshot  JMX bean 'debezium.vitess:type=connector-metrics,context=snapshot,server=dev.byuser' registered   [io.debezium.metrics.Metrics]

      What behaviour do you see?

      But the following warnings when both task 0 and task 1 are running inside the same JVM:

       

      2023-04-11 04:52:29,453 WARN   Vitess|dev.byuser|snapshot  Unable to register metrics as an old set with the same name debezium.vitess:type=connector-metrics,context=snapshot,server=dev.byuser exists, retrying in PT5S (attempt 1 out of 12)  [io.debezium.metrics.Metrics]

       

      Although this was just a warning in the log, but it's going to retry for 12 times which significantly slows down the startup phase, and in the end we are still missing imx bean metrics for some tasks.

      Do you see the same behaviour using the latest relesead Debezium version?

      (Ideally, also verify with latest Alpha/Beta/CR version)

      Yes

      Do you have the connector logs, ideally from start till finish?

      (You might be asked later to provide DEBUG/TRACE level log)

      2023-04-11 04:52:29,452 INFO   Vitess|dev.byuser|snapshot  JMX bean 'debezium.vitess:type=connector-metrics,context=snapshot,server=dev.byuser' registered   [io.debezium.metrics.Metrics]

      2023-04-11 04:52:29,453 WARN   Vitess|dev.byuser|snapshot  Unable to register metrics as an old set with the same name debezium.vitess:type=connector-metrics,context=snapshot,server=dev.byuser exists, retrying in PT5S (attempt 1 out of 12)   [io.debezium.metrics.Metrics]

      2023-04-11 04:52:29,454 INFO   Vitess|dev.byuser|snapshot  JMX bean 'debezium.vitess:type=connector-metrics,context=streaming,server=dev.byuser' registered   [io.debezium.metrics.Metrics]

      How to reproduce the issue using our tutorial deployment?

      Configure vitess connector in multitasking mode:

       

          *    {}"tasks.max"{}:{} "2",{*}

      Feature request or enhancement

      For feature requests or enhancements, provide this information, please:

      Which use case/requirement will be addressed by the proposed feature?

      Launching multiple tasks for vitess connector with a clean log and no delay in startup.

      Implementation ideas (optional)

      The root cause is the two connector tasks have the same connector name.  We need to add in the connector task id as the tiebreaker in the MBean name.

      Example of passing in taskId is here from MongoDbConnector: https://github.com/debezium/debezium/blob/main/debezium-connector-mongodb/src/main/java/io/debezium/connector/mongodb/metrics/MongoDbStreamingChangeEventSourceMetrics.java#L34

      super(taskContext, changeEventQueueMetrics, eventMetadataProvider,
      Collect.linkMapOf("context", "streaming", "server", taskContext.getConnectorName(), "task", taskContext.getTaskId()));

       

      For Vitess, the fix would be in VitessConnectorTask https://github.com/debezium/debezium-connector-vitess/blob/main/src/main/java/io/debezium/connector/vitess/VitessConnectorTask.java#L106:

      Instead of using 

      `DefaultChangeEventSourceMetricsFactory`, we will create our own VitessChangeEventSourceMetricsFactory and inside our own factory implement 

      `getStreamingMetrics` method to pass in `vitessConnectorConfig.getVitessTaskKey()`

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              haiyingcai Henry Haiying Cai (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: