Hi All, I'm trying to synchronize my OLTP Mysql d...
# troubleshooting
a
Hi All, I'm trying to synchronize my OLTP Mysql database with Apache Pinot. I have a sharded MySQL setup where every tenant has its own database and tables (Example tenant1.users, tenant2.users). Each tenant has tables (like users) with the same schema. My ETL pipeline between MySQL and Pinot currently ingests change log data from MySQL binlog into Kafka and then Kafka connect is used to feed the change log data to Pinot. How can I sync my sharded multitenant database without having to create schema configuration files for each table (Example tenant1.users, tenant2.users). Any help would be appreciated
f
Hey @Anshul, are you using Debezium to stream your CDC changes?
a
Yes, I'm using the same to capture binlogs and publish it to stream.
f
@Anshul You can apply a
RegexRouter
single-message transformer to the events generated by Debezium and merge all the rows from various tables into a single Kafka stream. Here's the relevant documentation for reference. https://docs.confluent.io/cloud/current/connectors/transforms/regexrouter.html
a
Will try this. Also, it would be great if you can please explain in understanding how using RegexRouter will help in syncing the data to Apache Pinot in the same structure data is in MySql, like syncing data to separate tenants with same set of tables and structure.
f
What you can do with RegexRouter is merge the separate Kafka streams generated by various tenant tables into a single stream with the table name. You can then use this stream as the input for the realtime table you'd like to create. So instead of tenant1.table1, you'd simply have table1 in Pinot. Does that answer the question
a
Okay understood, it means that the way to sync multi tenant data is syncing all the tenants data to one table itself. Won't that defeat the process of sharding data and increase the query processing time.
f
@Anshul It depends on what you're doing with the table. Pinot supports various types of indices which may help you stay performant even when you have many rows.
a
If I sync all tenants data to one table, I'll need column to identify which tenant data it is. The problem here is I don't have any specific column for this. Can I extract number from my database name say 1,2 from tenant1, tenant2 or from topic name which are like mysql.tenant1.users and add this as a field to key and value of the messages published to kafka for uniqueness.
f
@Anshul The Debezium payload contains the source information from which the row has been streamed. If you look at the JSON that's generated, you'd find the
source
object under the
payload
object. That'll give you all the information about the database and schema where the table is located. Here's one sample from the Postgres record.
Copy code
"source": {
            "version": "3.0.0.Final",
            "connector": "postgresql",
            "name": "microservice",
            "ts_ms": 1736576448655,
            "snapshot": "incremental",
            "db": "postgres",
            "sequence": "[\"63585008\",\"63585008\"]",
            "ts_us": 1736576448655046,
            "ts_ns": 1736576448655046700,
            "schema": "public",
            "table": "orders",
            "txId": null,
            "lsn": null,
            "xmin": null
        }
In essence, you can merge the streams and extract, say, the database and the schema name into a Pinot column to know the source of your data.
a
In MySQL we have allowed null values for all the datatypes, but in Apache Pinot I'm not able to sync date values in correct format that they exist in MySQL. Also, for all other datatypes, I want them to sync as it is, with null values, without converting columns to string.
f
@Anshul If you have a date column with null values in them, some of them would be non-zero long values representing milliseconds since epoch. You could enable column-level null handling in Pinot and designate, say, -1 to represent null. As an example, here's a sample field definition for a nullable column.
Copy code
{
  "name": "deleted_at",
  "dataType": "LONG",
  "format": "1:MILLISECONDS:EPOCH",
  "granularity": "1:MILLISECONDS",
  "defaultNullValue": "-1"
}
a
I have date values as 2019-08-18 in MYSQL, and I want them to sync as it is to Pinot database
f
@Anshul Debezium would convert them to milliseconds since epoch.
a
Is there anyway to handle so that data looks same way it is in MySql
f
You could apply a field-level transform and convert the millis to a date-formatted string. What's your use-case with dates? Is it time-based filtering?
a
Yes, I want to have filtering for all datatypes
Also, I want to store data in Pinot as close to datatypes they can be stored, instead of storing all in string, but MySQL have null values as well
f
Okay. If your date column is stored as millis since epoch, you could use a combination of
ago()
and range indexes to keep your query performant. For example,
Copy code
SELECT ...
FROM table
WHERE datecol >= ago('P90D')
a
With date values, which don't have timestamp, are converted as -7439
f
What's the value for that column in your Debezium payload?
a
Same as it is in debezium
f
I meant to ask what is Debezium sending you?
a
Both debezium and pinot shows -7439 type values for dates
f
Okay, you'll have to refer to the Debezium docs for your specific version of the connector to find out what the default value for null is.
AFAIK, you should get
null
in JSON.
the field will be skipped.
a
So there's any way that I can store columns close to datatypes like int, double, and so on with null values, without making them string in Apache Pinot
Fields are not skipped, I get null for the values where it is null in MySQL
f
Yes, you'll have to assign a default null value. Have a look at the doc and the snippet I mentioned earlier.
Okay, Postgres connector skips them in v3.0.0 of Debezium. Perhaps MySQL connector is different.
a
Still have this error
f
The change needs to be to the schema config.
You'd define the column as being nullable in your schema.
a
I have already added that
f
You'll also have to enable column-level null handling.
"enableColumnBasedNullHandling": true
a
Already added
f
Okay, could you post one of your field configs here?
a
Copy code
{
  "name": "sbid",
  "dataType": "INT",
  "defaultNullValue": 0,
  "notNull": false
}
f
You'll have to quote the zero after
defaultNullValue
.
a
Still error
f
Posting relevant part of the documentation here.
All your
defaultNullValue
values would need to be string.
a
yes, I have changed that, all values as "0"
f
Hmm, post your entire schema as a snippet here, please. Also mention what version of Pinot you're on.
a
I'm using pinot version 1.1.0
f
If you could post your schema, I can try and replicate the issue.
a
{
"schemaName": "clients", "enableColumnBasedNullHandling": true, "dimensionFieldSpecs": [ { "name": "appid", "dataType": "INT", "notNull": true }, { "name": "bid", "dataType": "INT", "notNull": true }, { "name": "title", "dataType": "STRING" }, { "name": "name", "dataType": "STRING", "notNull": true }, { "name": "pan", "dataType": "STRING" }, { "name": "createdBy", "dataType": "STRING" }, { "name": "aadhaarNo", "dataType": "STRING" }, { "name": "appcode", "dataType": "STRING" }, { "name": "checksum", "dataType": "STRING" }, { "name": "source", "dataType": "STRING" }, { "name": "action", "dataType": "STRING" }, { "name": "grpid", "dataType": "INT", "defaultNullValue": "0", "notNull": false }, { "name": "sbid", "dataType": "INT", "defaultNullValue": "0", "notNull": false }, { "name": "rmid", "dataType": "INT", "defaultNullValue": "0", "notNull": false }, { "name": "servicermid", "dataType": "INT", "defaultNullValue": "0", "notNull": false }, { "name": "liquiloanNo", "dataType": "INT", "defaultNullValue": "0", "notNull": false }, { "name": "fhid", "dataType": "INT", "defaultNullValue": "0", "notNull": false }, { "name": "modelid", "dataType": "INT", "defaultNullValue": "0", "notNull": false }, { "name": "uid", "dataType": "INT", "defaultNullValue": "0", "notNull": false }, { "name": "updateLock", "dataType": "INT", "defaultNullValue": "0", "notNull": false }, { "name": "inMergeProcess", "dataType": "INT", "defaultNullValue": "0", "notNull": false }, { "name": "hierarchyTouch", "dataType": "INT", "defaultNullValue": "0", "notNull": false }, { "name": "mftouched", "dataType": "INT", "defaultNullValue": "0", "notNull": false }, { "name": "touched", "dataType": "INT", "defaultNullValue": "0", "notNull": false }, { "name": "updatedBy", "dataType": "INT", "defaultNullValue": "0", "notNull": false }, { "name": "bid_appid", "dataType": "STRING" }, { "name": "__deleted", "dataType": "BOOLEAN" } ], "dateTimeFieldSpecs": [ { "name": "openingDate", "dataType": "STRING", "defaultNullValue": null }, { "name": "updatedAt", "dataType": "TIMESTAMP" }, { "name": "createdAt", "dataType": "TIMESTAMP" } ], "primaryKeyColumns": [ "bid_appid" ] }
f
Copy code
{
            "name": "openingDate",
            "dataType": "STRING",
            "defaultNullValue": null
        },
null
cannot be a default null value.
Also, all columns without
notNull: false
are implicitly nullable. So you may want to handle them appropriately.
a
Copy code
{
  "schemaName": "clients",
  "enableColumnBasedNullHandling": true,
  "dimensionFieldSpecs": [
    {
      "name": "appid",
      "dataType": "INT",
      "notNull": true
    },
    {
      "name": "bid",
      "dataType": "INT",
      "notNull": true
    },
    {
      "name": "title",
      "dataType": "STRING",
      "notNull": false
    },
    {
      "name": "name",
      "dataType": "STRING",
      "notNull": true
    },
    {
      "name": "pan",
      "dataType": "STRING",
      "notNull": false
    },
    {
      "name": "createdBy",
      "dataType": "STRING",
      "notNull": false
    },
    {
      "name": "aadhaarNo",
      "dataType": "STRING",
      "notNull": false
    },
    {
      "name": "appcode",
      "dataType": "STRING",
      "notNull": false
    },
    {
      "name": "checksum",
      "dataType": "STRING",
      "notNull": false
    },
    {
      "name": "source",
      "dataType": "STRING",
      "notNull": false
    },
    {
      "name": "action",
      "dataType": "STRING",
      "notNull": false
    },
    {
      "name": "grpid",
      "dataType": "INT",
      "defaultNullValue": "0",
      "notNull": false
    },
    {
      "name": "sbid",
      "dataType": "INT",
      "defaultNullValue": "0",
      "notNull": false
    },
    {
      "name": "rmid",
      "dataType": "INT",
      "defaultNullValue": "0",
      "notNull": false
    },
    {
      "name": "servicermid",
      "dataType": "INT",
      "defaultNullValue": "0",
      "notNull": false
    },
    {
      "name": "liquiloanNo",
      "dataType": "INT",
      "defaultNullValue": "0",
      "notNull": false
    },
    {
      "name": "fhid",
      "dataType": "INT",
      "defaultNullValue": "0",
      "notNull": false
    },
    {
      "name": "modelid",
      "dataType": "INT",
      "defaultNullValue": "0",
      "notNull": false
    },
    {
      "name": "uid",
      "dataType": "INT",
      "defaultNullValue": "0",
      "notNull": false
    },
    {
      "name": "updateLock",
      "dataType": "INT",
      "defaultNullValue": "0",
      "notNull": false
    },
    {
      "name": "inMergeProcess",
      "dataType": "INT",
      "defaultNullValue": "0",
      "notNull": false
    },
    {
      "name": "hierarchyTouch",
      "dataType": "INT",
      "defaultNullValue": "0",
      "notNull": false
    },
    {
      "name": "mftouched",
      "dataType": "INT",
      "defaultNullValue": "0",
      "notNull": false
    },
    {
      "name": "touched",
      "dataType": "INT",
      "defaultNullValue": "0",
      "notNull": false
    },
    {
      "name": "updatedBy",
      "dataType": "INT",
      "defaultNullValue": "0",
      "notNull": false
    },
    {
      "name": "bid_appid",
      "dataType": "STRING",
      "notNull": true
    },
    {
      "name": "__deleted",
      "dataType": "BOOLEAN",
      "notNull": true
    }
  ],
  "dateTimeFieldSpecs": [
    {
      "name": "openingDate",
      "dataType": "STRING",
      "notNull": false
    },
    {
      "name": "updatedAt",
      "dataType": "TIMESTAMP",
      "notNull": true
    },
    {
      "name": "createdAt",
      "dataType": "LONG",
      "defaultNullValue": "0"
    }
  ],
  "primaryKeyColumns": [
    "bid_appid"
  ]
}
still getting error
f
The issue is that you've defined your
dateTimeFieldSpecs
incorrectly. You'll have to add the format, granularity, etc. Please refer to the docs and add them appropriately.
If you'd like to see your schema work, try sending an empty array for
dateTimeFieldSpecs
and you'll notice that the schema gets added. Once you add them back in, you'll see the error you'd mentioned about.
a
It works, but no data is synced
When there is issue with any of the field, none of data gets synced, how to identify the same
f
Data is synced after you add the table.
a
no, its not synced
Hi, need one more help!! In my Pinot Query, I'm trying to use sum on column, based on case query. It's like case when c1, sum(col1) else col2 end as colName But sum is not working in any way. I'm using 1.1.0.
I need to understand, that if I have realtime tables, and I'm having schema changes in MySQL database, how can I reflect the same in Pinot tables with zero downtime
Hello All, can someone please suggest how to do deployment with zero downtime when I have realtime tables
m
Both schema evolution and deployment are zero downtime operations out of the box. For deployment you should run with replication > 1 and perform rolling restart
a
Currently I have one json column, but when I'm trying to use json match in my query it's giving error, how can I define the config so that this works fine