简体   繁体   English

超时直到重启

[英]Time-out until restart

I set up a cassandra cluster with 2 nodes. 我建立了一个有2个节点的cassandra集群。 After a couple thousand of writes, it starts throwing TimeOut exceptions that don't go away until after I restart the cassandra services. 经过数千次写操作后,它开始抛出TimeOut异常,直到我重新启动cassandra服务后,该异常才会消失。 I am using phpcassa (latest at time of writing). 我正在使用phpcassa(在撰写本文时为最新)。

Cassandra.yaml both Cassandra.yaml都

  • cluster_name: 'Test Cluster' cluster_name:“测试集群”
  • seed_provider: seed_provider:
    • class_name: org.apache.cassandra.locator.SimpleSeedProvider class_name:org.apache.cassandra.locator.SimpleSeedProvider
  • parameters: 参数:
    • seeds: "192.168.2.101" 种子:“ 192.168.2.101”
  • rpc_address: 0.0.0.0 rpc_address:0.0.0.0
  • rpc_port: 8080 rpc_port:8080

Cassandra.yaml 1 Cassandra.yaml 1

  • initial_token: 0 initial_token:0
  • listen_address: 192.168.2.101 listen_address:192.168.2.101

Cassandra.yaml 2 Cassandra.yaml 2

  • initial_token: 85070591730234615865843651857942052864 initial_token:85070591730234615865843651857942052864
  • listen_address: 192.168.2.102 listen_address:192.168.2.102

Assuming this configuration is correct, there must be an issue with my code. 假设此配置正确,则我的代码必须存在问题。 Here's the test script I made to reproduce the error: 这是我用来重现错误的测试脚本:

$pool = Config::ConnectionPool();
$stressTest = new ColumnFamily($pool, 'TwitterTest');
$id = 392766928478932992;

while(true)
{
    try
    {
        $stressTest->insert($id++, array("analyzed"=>0, "followersCount"=>"35",
            "friendsCount"=>"30", "lang"=>"en", "listedCount"=>"0",
            "name"=>"Henky Tanky", "statusesCount"=>"X", "text"=>"@HERPDERP dude i kno i lost a 16gb flash drive #MEH",
            "time"=>"2013-10-22 23:38:27", "twitterId"=>"392766928478932992", "username"=>"mehzor"),
            null, null, \cassandra\ConsistencyLevel::ANY);
    }
    catch (Exception $ex){
        print_r($ex);
        exit;
    }
}

class Config {
    static function ConnectionPool(){
        return new ConnectionPool('KSTwit', array('192.168.2.101:8080', '192.168.2.102:8080'));
    }
}

With that config I get a 'cassandra\\TimedOutException' (Stacktrace 1) 通过该配置,我得到一个'cassandra \\ TimedOutException'(Stacktrace 1)

// Set max-retries to 5, and read/write timeout to 60 seconds
new ConnectionPool('KSTwit', array('192.168.2.101:8080', '192.168.2.102:8080'), NULL, 5, 60000, 60000);

With that config I get a 'Thrift\\Exception\\TTransportException' (Stacktrace 2) 通过该配置,我得到一个“ Thrift \\ Exception \\ TTransportException”(Stacktrace 2)

I have tried various ConsistencyLevels; 我已经尝试过各种ConsistencyLevels。 ONE, QUORUM and ANY. 一,定额和任何。 Same issue with all of them. 所有这些都有同样的问题。

As I said, the exceptions don't occur until after a couple throusand of writes. 正如我所说,只有在写了几千次之后,才会出现异常。 However, if I restart the script after an exception ocurred it will throw exceptions immediately. 但是,如果在发生异常后重新启动脚本,它将立即引发异常。 I have to restart the cassandra services and then it can take a couple thousand again. 我必须重新启动cassandra服务,然后它可能又要花费几千美元。 This only seems to occur with writes. 这似乎仅在写入时发生。 It also occurs if I don't use counter columns so it's not an issue with that. 如果我不使用计数器列,也会发生这种情况,这不是问题。

Stack trace 1 堆栈跟踪1

Error performing add on 192.168.2.101:8080: exception 'cassandra\TimedOutException' in /var/installstuff/cassphp/lib/Thrift/Base/TBase.php:206
Stack trace:
#0 /var/installstuff/cassphp/lib/cassandra/Cassandra.php(3575): Thrift\Base\TBase->_read('Cassandra_add_r...', Array, Object(Thrift\Protocol\TBinaryProtocolAccelerated))
#1 /var/installstuff/cassphp/lib/cassandra/Cassandra.php(768): cassandra\Cassandra_add_result->read(Object(Thrift\Protocol\TBinaryProtocolAccelerated))
#2 /var/installstuff/cassphp/lib/cassandra/Cassandra.php(728): cassandra\CassandraClient->recv_add()
#3 [internal function]: cassandra\CassandraClient->add('All Tweets', Object(cassandra\ColumnParent), Object(cassandra\CounterColumn), 1)
#4 /var/installstuff/cassphp/lib/phpcassa/Connection/ConnectionPool.php(264): call_user_func_array(Array, Array)
#5 /var/installstuff/cassphp/lib/phpcassa/ColumnFamily.php(44): phpcassa\Connection\ConnectionPool->call('add', 'All Tweets', Object(cassandra\ColumnParent), Object(cassandra\CounterColumn), 1)
#6 /var/installstuff/cassphp/examples/db/TweetDatabase.php(103): phpcassa\ColumnFamily->add('All Tweets', 'Total')
#7 /var/installstuff/cassphp/examples/core/Helper.php(16): {closure}()
#8 /var/installstuff/cassphp/examples/db/TweetDatabase.php(104): Helper::DoForgiving(Object(Closure))
#9 /var/installstuff/cassphp/examples/core/twitterParser.php(98): TweetDatabaseCassandra->AddTweet('392633738364190...', Array)
#10 /var/installstuff/cassphp/examples/core/twitterParser.php(192): TwitterParser->RunOnce()
#11 /var/installstuff/cassphp/examples/runners/twitterParserCassandra.php(19): TwitterParser->Run()
#12 {main}

Stack trace 2 堆栈跟踪2

Error performing add on 192.168.2.101:8080: exception 'Thrift\Exception\TTransportException' with message 'TSocket: timed out reading 4 bytes from 192.168.2.101:8080' in /var/installstuff/cassphp/lib/Thrift/Transport/TSocket.php:284
Stack trace:
#0 /var/installstuff/cassphp/lib/Thrift/Transport/TTransport.php(74): Thrift\Transport\TSocket->read(4)
#1 /var/installstuff/cassphp/lib/Thrift/Transport/TFramedTransport.php(139): Thrift\Transport\TTransport->readAll(4)
#2 /var/installstuff/cassphp/lib/Thrift/Transport/TFramedTransport.php(106): Thrift\Transport\TFramedTransport->readFrame()
#3 /var/installstuff/cassphp/lib/Thrift/Transport/TTransport.php(74): Thrift\Transport\TFramedTransport->read(4)
#4 /var/installstuff/cassphp/lib/Thrift/Protocol/TBinaryProtocol.php(305): Thrift\Transport\TTransport->readAll(4)
#5 /var/installstuff/cassphp/lib/Thrift/Protocol/TBinaryProtocol.php(197): Thrift\Protocol\TBinaryProtocol->readI32(NULL)
#6 /var/installstuff/cassphp/lib/cassandra/Cassandra.php(760): Thrift\Protocol\TBinaryProtocol->readMessageBegin(NULL, 0, 0)
#7 /var/installstuff/cassphp/lib/cassandra/Cassandra.php(728): cassandra\CassandraClient->recv_add()
#8 [internal function]: cassandra\CassandraClient->add('All Tweets', Object(cassandra\ColumnParent), Object(cassandra\CounterColumn), 1)
#9 /var/installstuff/cassphp/lib/phpcassa/Connection/ConnectionPool.php(264): call_user_func_array(Array, Array)
#10 /var/installstuff/cassphp/lib/phpcassa/ColumnFamily.php(44): phpcassa\Connection\ConnectionPool->call('add', 'All Tweets', Object(cassandra\ColumnParent), Object(cassandra\CounterColumn), 1)
#11 /var/installstuff/cassphp/examples/db/TweetDatabase.php(103): phpcassa\ColumnFamily->add('All Tweets', 'Total')
#12 /var/installstuff/cassphp/examples/core/Helper.php(17): {closure}()
#13 /var/installstuff/cassphp/examples/db/TweetDatabase.php(104): Helper::DoForgiving(Object(Closure))
#14 /var/installstuff/cassphp/examples/core/twitterParser.php(98): TweetDatabaseCassandra->AddTweet('392642135327264...', Array)
#15 /var/installstuff/cassphp/examples/core/twitterParser.php(192): TwitterParser->RunOnce()
#16 /var/installstuff/cassphp/examples/runners/twitterParserCassandra.php(19): TwitterParser->Run()
#17 {main}

The cassandra log doesn't really show anything interesting. cassandra日志并没有真正显示出任何有趣的内容。 Except for this ocurring a lot, but that happens even when the exceptions don't occur so I don't think it's the issue; 除了发生这种情况以外,即使没有发生异常,这种情况也会发生,所以我认为这不是问题。

INFO 10:58:58,241 Timed out replaying hints to /192.168.2.102; aborting further deliveries
WARN 11:07:17,979 MemoryMeter uninitialized (jamm not specified as java agent); assuming liveRatio of 10.0.  Usually this means cassandra-env.sh disabled jamm because you are using a buggy JRE; upgrade to the Sun JRE instead

Keyspace is setup using 'SIMPLE_STRATEGY' and 'replication_factor=2' According to the 'nodetool ring' command on both machines, the nodes are functioning 'normal' even after the exceptions have been triggered. 使用'SIMPLE_STRATEGY'和'replication_factor = 2'设置密钥空间根据两台计算机上的'nodetool ring'命令,即使触发了异常,节点也可以正常运行。 I honestly don't know what to try next, can anyone spot the issue? 老实说,我不知道下一步该怎么做,有人能发现这个问题吗?

I fixed the issue in one of two ways (can't be sure.) 我通过以下两种方式之一解决了此问题(不确定)。

I initially installed cassandra using a guide online which listed these repo's; 我最初使用在线指南安装了cassandra,其中列出了这些存储库。

deb http://www.apache.org/dist/cassandra/debian 11x main
deb-src http://www.apache.org/dist/cassandra/debian 11x main

These are outdated, there's a 20x version, so I updated to that. 这些已经过时,有20x版本,所以我更新了。

I also replaced jsvc with sun's java. 我还用sun的java替换了jsvc It's all working fine now. 现在一切正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM