Rohit
05/13/2026, 11:21 AMRocky
05/13/2026, 11:22 AMbinlog.enable property to true when creating the table or by altering an existing table.
• This is typically used with the Primary Key model to capture record-level changes effectively.
sql
-- Example: Enable binlog on an existing table
ALTER TABLE your_table SET ("binlog.enable" = "true");
2. Use the Flink StarRocks Connector as a Source
The Flink-connector-starrocks (v1.2.9 or later) supports reading from StarRocks in Source mode by consuming these binlogs.
• Source Config: In your Flink job, define a table using the starrocks connector. Flink will connect to the StarRocks FE/BE to fetch the change stream.
• Sink Config: Define a second table in Flink using the standard jdbc connector pointing to your PostgreSQL instance.
3. Handle Upsert in PostgreSQL
To achieve the "upsert" behavior in PostgreSQL:
• Ensure your Flink SQL job uses an INSERT INTO ... SELECT ... statement between the StarRocks source and the PostgreSQL sink.
• The Flink JDBC Sink handles upserts automatically for PostgreSQL if the target table has a primary key. It generates INSERT ... ON CONFLICT (...) DO UPDATE SET ... statements under the hood.
──────────
Alternative Approaches
* Third-Party Synchronization Tools:
StarRocks documentation highlights several ecosystem tools that support StarRocks as a source for replication:
* CloudCanal: Supports real-time incremental synchronization from StarRocks to PostgreSQL with a visual interface.
* BladePipe: A data migration and synchronization tool often recommended for StarRocks ecosystem tasks.
* Manual Batch Export (Non-Continuous):
If real-time synchronization is not required, you can use the EXPORT command to save data to S3/HDFS and then load it into PostgreSQL. However, this does not support native CDC/incremental upserts out of the box.
Important Limitations
* External Table Writing: While StarRocks supports JDBC External Tables for PostgreSQL, these are currently read-only. You cannot use INSERT INTO postgres_external_table SELECT ... to sync data from StarRocks to PostgreSQL; this feature is only supported for writing from one StarRocks cluster to another.
* Resource Usage: Enabling Binlog on a StarRocks table increases storage overhead (for the log files) and may have a minor impact on write performance.
References
• loading/Flink_cdc_load.md