I got an error when I have second execute
All host(s) tried for query failed. First host tried, 127.0.0.1:9042:
ResponseError: Not enough replicas available for query at consistency
QUORUM (2 required but only 1 alive). See innerErrors.
and i tried many thing to fixed this but nothing help
I have tried to change replication class from simplestartegy to networktopologystrategy also change replication factor to 3 but it doesn't work too.
this is my code main.js :
const cqsql = require('./cqlfunction')
let insert_cassandra = async () => {
try {
let get_id = `SELECT next_id FROM ids WHERE id_name = 'person_id'`
let last_id = await cqsql.cql_getofdb(get_id)
let next_id = last_id[0].next_id
let update_id = `UPDATE ids SET next_id = ${next_id + 1} WHERE id_name =
'person_id' IF next_id = ` + next_id
let result = await cqsql.cql_execute(update_id)
console.log(result);
} catch (error) {
console.log(error);
debugger
process.exit()
}
}
insert_cassandra()
cqlfunction.js :
const cassandra = require('cassandra-driver');
const client = new cassandra.Client({ contactPoints: ['127.0.0.1'], localDataCenter: 'datacenter1', keyspace: 'javafrm'});
exports.cql_getofdb = async (query) => {
try {
// await client.connect()
let result1 = await client.execute(query)
if (result1.rowLength > 0) {
return result1.rows
} else {
return []
}
} catch (error) {
debugger
console.error(error);
return error
}
}
exports.cql_execute = async (query) => {
try {
// await client.connect()
debugger
let result1 = await client.execute(query)
return {}
} catch (error) {
debugger
console.error(error);
return error
}
}