Overview
Duckling provides atomic, ACID-compliant synchronization from MySQL to DuckDB using the Sequential Appender architecture. All sync endpoints support multi-database operations via the?db={database_id} query parameter.
Sync Types
- Full Sync - Complete data refresh with atomic transactions
- Incremental Sync - Watermark-based delta updates (only changed records)
- Single Table Sync - Sync individual tables on-demand
Endpoints
POST /sync/full
Trigger a full synchronization from MySQL to DuckDB. Authentication: Required Query Parameters:Database ID to sync (defaults to
default if omitted)Total number of tables processed
Number of tables synced successfully
Number of tables that failed to sync
Total number of records synchronized
Total sync duration in milliseconds
List of error messages (if any)
POST /sync/incremental
Trigger an incremental synchronization using watermark-based tracking. Authentication: Required Query Parameters:Database ID to sync (defaults to
default if omitted)Incremental sync only processes records changed since the last watermark. This is significantly faster than full sync for tables with infrequent updates.
POST /sync/table/:tableName
Synchronize a specific table from MySQL to DuckDB. Authentication: Required Path Parameters:Name of the table to synchronize
Database ID (defaults to
default if omitted)Name of the synchronized table
Number of records synchronized
Sync duration in milliseconds
Sync status:
success or errorType of sync performed:
snapshot, micro-batch, or appendGET /sync/status
Get current synchronization status and recent sync history. Authentication: Required Query Parameters:Database ID (defaults to
default if omitted)Watermark information for incremental sync tracking
Table name
Last synchronized record ID
Timestamp of last synchronized record
Recent synchronization logs (last 100 operations)
GET /sync/validate
Validate data integrity by comparing record counts between MySQL and DuckDB. Authentication: Required Query Parameters:Database ID (defaults to
default if omitted)Number of tables with matching record counts
Number of tables with count discrepancies
List of tables with count mismatches
Overall sync accuracy percentage
DELETE /sync/clear-all
Clear all DuckDB data and reinitialize the database. Authentication: Required Query Parameters:Database ID (defaults to
default if omitted)Watermark-Based Incremental Sync
Duckling uses watermark tracking to efficiently synchronize only changed data.How It Works
-
Timestamp Detection - Automatically detects the appropriate timestamp column:
- Priority 1:
updatedAt,updated_at,modifiedAt,modified_at - Priority 2:
createdAt,created_at - Priority 3:
timestamp
- Priority 1:
- Watermark Storage - Stores the last processed timestamp for each table
-
Delta Queries - Fetches only records changed since the watermark:
-
Upsert Behavior - Uses
INSERT OR REPLACEto handle updates:- New records are inserted
- Modified records replace existing rows by primary key
- No duplicates (primary key constraint enforced)
Example Sync Flow
Incremental sync is 650x faster than full sync for databases with low update rates.
Error Handling
409 Conflict - Sync Already Running:Best Practices
- Use Incremental Sync - Run incremental sync every 15 minutes via automation
- Schedule Full Sync - Run full sync daily during off-peak hours
- Monitor Logs - Check
/sync/statusfor failed tables and errors - Validate Periodically - Run
/sync/validateweekly to ensure data integrity - Clear Carefully - Only use
/sync/clear-allwhen absolutely necessary