5

I'm trying to migrate a SQL Server table using AWS DMS to a DynamoDb target. The table structure is as follows:

|SourceTableID|Title      |Status|Display|LongDescription|
|-------------|-----------|------|-------|---------------|
|VARCHAR(100) |VARCHAR(50)|INT   |BIT    |NVARCHAR(MAX)  |

Every field is being migrated without errors and is present in my target DynamoDb table except for the LongDescription column. This is because it is a NVARCHAR(MAX) column.

According to the documentation:

The following limitations apply when using DynamoDB as a target:

  • AWS DMS doesn't support LOB data unless it is a CLOB. AWS DMS converts CLOB data into a DynamoDB string when migrating data.

https://docs.aws.amazon.com/dms/latest/userguide/CHAP_Target.DynamoDB.html

Source Data Types for SQL Server

|SQL Server Data Types|AWS DMS Data Types|
|----------------------------------------|
|NVARCHAR (max)       |NCLOB, TEXT       |

https://docs.aws.amazon.com/dms/latest/userguide/CHAP_Source.SQLServer.html

Depending on my task configuration the following two scenarios occur:

  • Limited LOB mode: Information for the LongDescription column is being migrated properly to DynamoDb, however the text is truncated
  • Full LOB mode: Information for the LongDescription column is NOT migrated properly to DynamoDb

How can I correctly migrate an NVARCHAR(MAX) column to DynamoDb without losing any data? Thanks!

Progress Report

  1. I have already tried migrating to an S3 target. However it looks like S3 doesnt support Full LOB

    Limitations to Using Amazon S3 as a Target

    • Full LOB mode is not supported.

https://docs.aws.amazon.com/dms/latest/userguide/CHAP_Target.S3.html

  1. I cannot use the compress T-SQL command in order to store the LongDescription column as a binary, since my SQLServer version is 2014

  2. I tried to run the migration task to Limited LOB mode and use the maximum byte size as the limit. My maximum byte size is 45155996 so I set 46000KB as the limit. This results in an error as follows:

Failed to put item into table 'TestMigration_4' with data record with source PK column 'SourceTableID' and value '123456'

luisgepeto
  • 763
  • 1
  • 11
  • 36

1 Answers1

4

You might want to check this AWS' best practices page for storing large items/attributes in DynamoDB:

If your application needs to store more data in an item than the DynamoDB size limit permits, you can try compressing one or more large attributes or breaking the item into multiple items (efficiently indexed by sort keys). You can also store the item as an object in Amazon Simple Storage Service (Amazon S3) and store the Amazon S3 object identifier in your DynamoDB item.

I actually like the idea of saving your LongDescription in S3 and referencing its identifier in DynamoDB. I never tried, but an idea would be to use their DMS ability to create multiple migration tasks to perform this, or even create some kind of ETL solution as last resort, making use of DMS' CDC capability. You might want to get in touch with their support team to make sure it works.

Hope it helps!

Fabio Manzano
  • 2,847
  • 1
  • 11
  • 23
  • Reading throught the documentation it seems that Full LOB mode is not supported with S3 as a target. Running a migration task this way just ignores the `LongDescription` column https://docs.aws.amazon.com/dms/latest/userguide/CHAP_Target.S3.html – luisgepeto Sep 19 '19 at 20:54
  • But why don't you go with limited LOB mode while migrating to S3? Did you see this paper with best practices migrating LOBs? https://docs.aws.amazon.com/dms/latest/userguide/CHAP_Tasks.LOBSupport.html – Fabio Manzano Sep 19 '19 at 21:06
  • Because with limited LOB I would lose information so I dont want the column to be truncated – luisgepeto Sep 20 '19 at 15:22
  • Can't you configure it based upon your largest LOB item? – Fabio Manzano Sep 20 '19 at 16:29
  • I have already tried that. My `LongDescription` column contains maximum 45155996 bytes. I set the maximum LOB size to 46000 KB but I get the following error: `Failed to put item into table 'TestMigration_4' with data record with source PK column 'SourceTableID' and value '123456'` – luisgepeto Sep 20 '19 at 22:38
  • But you got this error migrating to DynamoDB, right? What about S3? – Fabio Manzano Sep 20 '19 at 22:56
  • That is correct, the error was on DynamoDB. I already tried the S3 approach and it looks like it worked correctly, will continue working down this path and see if there are any other issues – luisgepeto Sep 24 '19 at 17:00
  • Happy to hear that! – Fabio Manzano Sep 24 '19 at 17:12
  • A potential problem might be that it seems that the maximum file size that can be created is 1GB, and my `LongDescription` column is at least 50GB in size... I could create several DMS tasks to solve this, but do you think that this can be solved some other way? https://docs.aws.amazon.com/dms/latest/userguide/CHAP_Target.S3.html#CHAP_Target.S3.Configuring – luisgepeto Sep 24 '19 at 17:18
  • I'd definitely contact their support to recommend how to proceed. It's not clear in the documentation if it will split your data in many CSVs of 1GB or fail somehow, as your LOB exceeds the limit. I'm curious. – Fabio Manzano Sep 24 '19 at 18:17