- Newest
- Most votes
- Most comments
The issue you're experiencing with your multi-tenant schema replication task failing when new schemas are created is related to how AWS DMS handles schema changes during ongoing replication.
The primary reason your multi-tenant task fails is that AWS DMS doesn't automatically detect and incorporate new tables or schemas that match your pattern rules after the task has started. This is a known limitation when working with pattern-based mappings.
Here are some key points to understand and potential solutions:
-
Primary Key Requirement: Ensure all tables in your source database have primary keys. AWS DMS ignores DELETE and UPDATE operations for tables without primary keys when using PostgreSQL as a source. This is especially important for CDC operations.
-
Task Handling of New Objects: By default, DMS doesn't automatically detect and start replicating new tables that match your selection patterns after the task has started. When a new schema is created that matches your pattern, the task may fail because it wasn't part of the initial metadata collection.
-
Potential Solutions:
a. Reload Task Metadata: You can stop the task, modify it to reload the table metadata, and then restart it. This will incorporate the new schemas/tables.
b. Create Separate Tasks: Consider having one task for initial schemas and separate tasks for new schemas as they're added.
c. Use Task Settings for Schema Changes: Adjust your task settings to better handle schema changes. In particular, review the ChangeProcessingDdlHandlingPolicy settings in your task configuration.
-
Monitoring and Error Handling: Implement robust monitoring using CloudWatch to detect when tasks fail due to schema changes. Set up appropriate error handling in your task settings to determine whether the task should log errors, suspend tables, or stop entirely when issues occur.
-
Testing Strategy: Develop a testing strategy that includes scenarios where new schemas are added during replication to validate your configuration changes.
For your specific multi-tenant architecture, consider implementing a process where you temporarily pause replication, reload metadata when new tenants are added, and then resume replication. Alternatively, you might explore using AWS DMS's table-mapping transformation rules more extensively to handle the dynamic nature of your multi-tenant environment.
Sources
AWS DMS implementation guide: Building resilient database migrations through testing, monitoring, and SOPs | AWS Database Blog
Using a PostgreSQL database as an AWS DMS source - AWS Database Migration Service
