php-cassandra-binary icon indicating copy to clipboard operation
php-cassandra-binary copied to clipboard

Unavailable exception

Open trK54Ylmz opened this issue 9 years ago • 5 comments

Here is my code. I think there is a encoding/decoding or response parse problem.

require_once 'vendor/autoload.php';

$nodes = array(
    '127.0.0.1:9042' => array(
        'username'  => 'cassandra',
        'password'  => 'cassandra'
    )
);

try {
    $database = new evseevnn\Cassandra\Database($nodes, 'test');
    $database->connect();

    $users = $database->query('SELECT * FROM user');

    var_dump($users);
} catch (evseevnn\Cassandra\Exception\CassandraException $e) {
   echo $e->getMessage() . PHP_EOL;
}

And exception message is:

Unavailable exception. Error data: array (
  'consistency' => 2573153,
  'node' => 1852731252,
  'replica' => 543253352,
)

CQL shell output:

cqlsh:test> SELECT * FROM user;

 id                                   | activated | name         | password | regdate                  | status | username
--------------------------------------+-----------+--------------+----------+--------------------------+--------+----------
 ef8949f0-09da-11e4-8132-e76149b7842c |     False | Tarık Yılmaz | pass1234 | 2014-01-01 13:45:12+0200 |  False |    tarik

(1 rows)

and finally stack trace

#0 /home/tarik/Desktop/cass/index.php(15): evseevnn\Cassandra\Database->query('SELECT * FROM u...')
#1 {main}

trK54Ylmz avatar Oct 05 '14 22:10 trK54Ylmz

Hey @trK54Ylmz , how is your keyspace set up? Do you have a high replication factor and not all shards available? Its true that we should send a exception that guides you towards this error better. Can you confirm, that this can be the issue?

LarsFronius avatar Oct 24 '14 15:10 LarsFronius

Hi @LarsFronius ,

I get the same problem :

Fatal error: Uncaught exception 'evseevnn\Cassandra\Exception\CassandraException' with message 'Unavailable exception. Error data: array ( 'consistency' => 2573153, 'node' => 1852731252, 'replica' => 543253352, )'

I have single node hosted on AWS; My test keyspace is : CREATE KEYSPACE test WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '3'} AND durable_writes = true;

Any suggestions how to fix it? Should I reduce the replication factor ?

bborisovs avatar Oct 29 '14 13:10 bborisovs

With a single node, there is no way to fulfil your replication_factor of 3 replicas, so Cassandra throws back that the keyspace is unavailable, which is what you see - the Error data array though is quite misleading. With a replication_factor set to 1, you should be fine @bborisov

LarsFronius avatar Oct 29 '14 13:10 LarsFronius

Thanks @LarsFronius that helped!

bborisovs avatar Oct 30 '14 09:10 bborisovs

@LarsFronius Thanks that helped me too. @evseevnn My problem solved. It was my test keyspace and replication_factor was set to 3. But,

Unavailable exception. Error data

in my opinion the error message should be better than this

trK54Ylmz avatar Nov 06 '14 15:11 trK54Ylmz