MariaDB Heartbeats
Setup MariaDB heartbeats for low and intermittent traffic databases
In low-traffic or intermittent databases, the log can become stale due to inactivity, which may cause the Connector to miss change events.
To prevent this, the heartbeat process — which runs within the Connector — periodically inserts or updates a record in the heartbeat table. This triggers a change event, keeping the logs active and ensuring that all changes are detected and captured by the Connector.
Table must exist in a schema called
streamkap
Setup Heartbeats
-- Create the streamkap schema
CREATE SCHEMA IF NOT EXISTS streamkap;
-- Switch to the streamkap schema
USE streamkap;
-- Create the heartbeat table with id, text, and last_update fields
CREATE TABLE streamkap_heartbeat (
id INT AUTO_INCREMENT PRIMARY KEY,
text TEXT,
last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);
-- Grant permission to the Streamkap user
GRANT SELECT, INSERT, UPDATE ON streamkap.streamkap_heartbeat TO STREAMKAP_USER;
-- Insert the first row into the heartbeat table
INSERT INTO streamkap_heartbeat (text) VALUES ('test_heartbeat');
Verify
- After a few minutes, look for entries with a recent timestamp in the heartbeat table to verify it's working
Updated 24 days ago