Search code examples
cassandracqlcqlsh

CQLSH : NoHostAvailable error Cassandra update fails update



THIS IS MY KEYSPACE

CREATE KEYSPACE db_space WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'}  AND durable_writes = true;

THIS IS MY TABLE

CREATE TABLE **db_space.user12** (
    id text PRIMARY KEY,
    details map<text, text>,
    services map<text, frozen<user_services>>
) WITH additional_write_policy = '99p'
    AND bloom_filter_fp_chance = 0.01
    AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
    AND comment = ''
    AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
    AND compression = {'chunk_length_in_kb': '16', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
    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 = 'BLOCKING'
    AND speculative_retry = '99p';

THE BELOW QUERY WORKS

update user12 set details=details + {'name':'raj'} where id = '2';

BUT WHEN I TRIED TO UPDATE A FIELD WITH UDT

update user12 set services = {'1298182':{'id':'2','title':'2','description':'2'}} where id = '2';

An error shows up , No Host Available

The issue happens only for this particular field ? I searched online and tried changing the network strategies , cluster names , nodetool repairs and lots of cassandra restarts too .. This shows the error


Solution

  • Your query is incorrect - field names in the UDT shouldn't be quoted, so it should be like this:

    update user12 set services = {'1298182':{id:'2', title:'2', description:'2'}} 
       where id = '2';
    

    Although I'm not sure why it shows NoHostAvailable - you need to check server-side logs. Look to system.log of the node.