'Getting AlreadyExistsException when creating table, even table is not found in aws keyspace

I am trying to create a table through following query on aws keyspace. it is throw an exception that "com.datastax.oss.driver.api.core.servererrors.AlreadyExistsException: Object ascend_dev.ascend_r_c_zzzj already exists", even table not found in keyspace.

CREATE TABLE ascend_dev.ascend_r_c_zzzg(id uuid PRIMARY KEY, seqno text  ,wtdrd text  ,drdrstz text  ,drexmer text  ,drabf text  ,drdint text  ,drday text  ,drlang text  ,drmnrsp text  ,drhelpd text  )  WITH bloom_filter_fp_chance = 0.01
   AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
   AND comment = ''
   AND crc_check_chance = 1.0
   AND default_time_to_live = 0
   AND gc_grace_seconds = 864000
   AND max_index_interval = 2048
   AND memtable_flush_period_in_ms = 0
   AND min_index_interval = 128
   AND read_repair_chance = 0.0
   AND speculative_retry = '99PERCENTILE';


Solution 1:[1]

DDL operations in AWS Keyspaces are asynchronous. It is possible it takes some time to do so. You can get in very rare timeframes where the table is created but not ready to be used (like terraform operations for some resources).

Best way is to create if not exists, and use retries / polling to check when it is available.

Solution 2:[2]

Table creation and modification is asynchronous. You can query for the table create status from the system table system_schema_mcs.tables. The following example we block until the table has a status of ACTIVE

while (session.execute(
       "SELECT status FROM system_schema_mcs.tables 
        WHERE keyspace_name = 'mykeyspacename' 
        AND table_name = 'mytablename'")
           .all().stream().noneMatch(x -> x.getString("status").equalsIgnoreCase("ACTIVE"))) {
                
                //Waiting 1s
                Thread.sleep(1000);
            }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 zenbeni
Solution 2 MikeJPR