If the "Don't support allow update operation on table with index and ttl" error message appears when you create a secondary index, make sure that updates to the data table are prohibited when the time to live (TTL) parameter is set to a value other than -1, or data in the data table never expires.

Problem description

The following error message appears when I create a secondary index:

ErrorCode: OTSParameterInvalid, ErrorMessage: Don't support allow update operation on table with index and ttl

Cause

The TTL parameter is set to a value other than -1 but the TableOptions.AllowUpdate parameter is not set to false.

Note
When you create a secondary index for a data table, the data table must meet one of the following conditions:
  • The TTL parameter of the data table is set to -1, which means that data in the data table never expires.
  • The TTL parameter of the data table is set to a value other than -1 and the TableOptions.AllowUpdate parameter is set to false.

Solution

Select a solution based on your business requirements.
  • If you want data in the data table to never expire, you can use the Tablestore console or Tablestore SDK to set the TTL parameter of the data table to -1.
    • Use the Tablestore console

      Log on to the Tablestore console and go to the Basic Information tab. Click Modify Attributes. In the dialog box that appears, set Time to Live to -1 and click OK.

    • Use the Tablestore SDK

      Call the UpdateTable operation to set the TableOptions.TimeToLive parameter to -1.

  • If you want to set the TTL parameter to a value other than -1, you can use the Tablestore SDK to prohibit updates to the data table.

    Call the UpdateTable operation to set the TableOptions.AllowUpdate parameter to false.

    Important After you prohibit updates to a data table, you cannot call the UpdateRow operation to update data in the data table.