node-cassandra-cql icon indicating copy to clipboard operation
node-cassandra-cql copied to clipboard

Post taking ~120000ms

Open ankitladhania opened this issue 11 years ago • 1 comments

screenshot from 2014-05-24 10 54 07 I dont know what is happening sometimes cassandra is easily committing the post and storing data in ~20ms and other times the post takes ~120000ms but the post is not committed(i.e stored). Any Suggestion Guys i'm struggling with this for two days I dont find any error in the bellow queries . I have indexed checked column.

  var queries={
insert:{
    sport_detail:{
        query:'INSERT INTO only_sport_detail(sportid,sport_name,sport_short_name,time_made,checked) VALUES (?,?,?,?,?)'
    },
    league_detail:{
        query:'INSERT INTO only_league_detail(leagueid,league_name,league_short_name,league_abbreviation,league_location,time_made,checked) VALUES (?,?,?,?,?,?,?)'
    }
},
retrieve:{
    sport_detail:{
        query:'SELECT * FROM only_sport_detail WHERE checked=?'
    },
    league_detail:{
        query:'SELECT * FROM only_league_detail WHERE checked=?'
    }
}
 };

   module.exports=function(app,cassandraConfig){
var cassandraClient=cassandraConfig.cassandraClient;
var writeConsistency=cassandraConfig.writeConsistency;
var readConsistency=cassandraConfig,readConsistency;
var cassandra=cassandraConfig.cassandra;
app.get('/insert/detail/sport',function(req,res){
    res.sendfile('views/insert/sport_detail.html');
});
app.post('/insert/detail/sport',function(req,res){
    sportid=cassandra.types.timeuuid();
    cassandraClient.executeAsPrepared(
        queries.insert.sport_detail.query,
        [sportid,req.body.sport_name,req.body.sport_short_name,{value: new Date(), hint: cassandra.types.dataTypes.timestamp},1],
        writeConsistency,
        function(err){
            if(!err)
            {

                cassandraClient.executeAsPrepared(
                    queries.retrieve.sport_detail.query,
                    [1],
                    function(err,result){
                        if(err)
                        {
                            console.log(err);
                            res.send('Sorry error');
                            res.end();
                        }
                        else
                        {
                            res.json(result.rows);
                            res.end();
                        }
                    }
                );
            }
        }
    );

});

app.get('/get/detail/sport',function(req,res){
    cassandraClient.executeAsPrepared(
        queries.retrieve.sport_detail.query,
        [1],
        function(err,result){
            if(err)
            {
                console.log(err);
                res.send('Sorry error');
                res.end();
            }
            else
            {
                res.json(result.rows);
                res.end();
            }
        }
    );
});

};

ankitladhania avatar May 24 '14 05:05 ankitladhania

I would recommend to try to isolate the problem by:

  • Adding logging using the client log event.
  • Making a small app without express to see where the problem actually is.

jorgebay avatar May 24 '14 20:05 jorgebay