Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

half of redis server are not available! #22

Open
nimaamiri92 opened this issue Sep 10, 2018 · 6 comments
Open

half of redis server are not available! #22

nimaamiri92 opened this issue Sep 10, 2018 · 6 comments

Comments

@nimaamiri92
Copy link

What is this this error?

It's not possible to acquire a lock because at least half of the Redis serv er are not available.

This is my code:

        $redis = new Client;
        $redis->auth(REDIS-PASSWORD,null);
        $redis->connect();
        $my_range = range(1,100);

        foreach ($my_range as $each_range){
            $mutex = new PredisMutex([$redis], "balance");
            $mutex->synchronized(function () use($each_range) {
                $this->use_this_range($each_range);
            });
        }
@willemstuursma
Copy link
Contributor

Please validate that the $redis object can connect to the Redis server.

@nimaamiri92
Copy link
Author

nimaamiri92 commented Sep 11, 2018

Im pretty sure!
without above pseudo code my $redis object work fine, but when add this code give this error

@ValeriiTsarov
Copy link

Im pretty sure!
without above pseudo code my $redis object work fine, but when add this code give this error

Did you check a result from $redis->connect();? This is a good practice to use x-debug and store any results to variables like this:

$result = $redis->connect();

@nimaamiri92
Copy link
Author

Im pretty sure!
without above pseudo code my $redis object work fine, but when add this code give this error

Did you check a result from $redis->connect();? This is a good practice to use x-debug and store any results to variables like this:

$result = $redis->connect();

You are right $redis->connect() return null because that's void function.
but the $redis variable contain:

Predis\Client {#806
  #connection: Predis\Connection\StreamConnection {#810
    -resource: stream resource {@496
      timed_out: false
      blocked: true
      eof: false
      stream_type: "tcp_socket/ssl"
      mode: "r+"
      unread_bytes: 0
      seekable: false
      options: []
    }
    -cachedId: null
    #parameters: Predis\Connection\Parameters {#808
      -parameters: array:3 [
        "scheme" => "tcp"
        "host" => "127.0.0.1"
        "port" => 6379
      ]
    }
    #initCommands: []
  }
  #options: Predis\Configuration\Options {#807
    #input: []
    #options: array:2 [
      "connections" => Predis\Connection\Factory {#809
        -defaults: []
        #schemes: array:6 [
          "tcp" => "Predis\Connection\StreamConnection"
          "unix" => "Predis\Connection\StreamConnection"
          "tls" => "Predis\Connection\StreamConnection"
          "redis" => "Predis\Connection\StreamConnection"
          "rediss" => "Predis\Connection\StreamConnection"
          "http" => "Predis\Connection\WebdisConnection"
        ]
      }
      "profile" => Predis\Profile\RedisVersion320 {#812
        -commands: array:159 [
          "EXISTS" => "Predis\Command\KeyExists"
          "DEL" => "Predis\Command\KeyDelete"
          "TYPE" => "Predis\Command\KeyType"
          "KEYS" => "Predis\Command\KeyKeys"
          "RANDOMKEY" => "Predis\Command\KeyRandom"
          "RENAME" => "Predis\Command\KeyRename"
          "RENAMENX" => "Predis\Command\KeyRenamePreserve"
          "EXPIRE" => "Predis\Command\KeyExpire"
          "EXPIREAT" => "Predis\Command\KeyExpireAt"
          "TTL" => "Predis\Command\KeyTimeToLive"
          "MOVE" => "Predis\Command\KeyMove"
          "SORT" => "Predis\Command\KeySort"
          "DUMP" => "Predis\Command\KeyDump"
          "RESTORE" => "Predis\Command\KeyRestore"
          "SET" => "Predis\Command\StringSet"
          "SETNX" => "Predis\Command\StringSetPreserve"
          "MSET" => "Predis\Command\StringSetMultiple"
          "MSETNX" => "Predis\Command\StringSetMultiplePreserve"
          "GET" => "Predis\Command\StringGet"
          "MGET" => "Predis\Command\StringGetMultiple"
          "GETSET" => "Predis\Command\StringGetSet"
          "INCR" => "Predis\Command\StringIncrement"
          "INCRBY" => "Predis\Command\StringIncrementBy"
          "DECR" => "Predis\Command\StringDecrement"
          "DECRBY" => "Predis\Command\StringDecrementBy"
          "RPUSH" => "Predis\Command\ListPushTail"
          "LPUSH" => "Predis\Command\ListPushHead"
          "LLEN" => "Predis\Command\ListLength"
          "LRANGE" => "Predis\Command\ListRange"
          "LTRIM" => "Predis\Command\ListTrim"
          "LINDEX" => "Predis\Command\ListIndex"
          "LSET" => "Predis\Command\ListSet"
          "LREM" => "Predis\Command\ListRemove"
          "LPOP" => "Predis\Command\ListPopFirst"
          "RPOP" => "Predis\Command\ListPopLast"
          "RPOPLPUSH" => "Predis\Command\ListPopLastPushHead"
          "SADD" => "Predis\Command\SetAdd"
          "SREM" => "Predis\Command\SetRemove"
          "SPOP" => "Predis\Command\SetPop"
          "SMOVE" => "Predis\Command\SetMove"
          "SCARD" => "Predis\Command\SetCardinality"
          "SISMEMBER" => "Predis\Command\SetIsMember"
          "SINTER" => "Predis\Command\SetIntersection"
          "SINTERSTORE" => "Predis\Command\SetIntersectionStore"
          "SUNION" => "Predis\Command\SetUnion"
          "SUNIONSTORE" => "Predis\Command\SetUnionStore"
          "SDIFF" => "Predis\Command\SetDifference"
          "SDIFFSTORE" => "Predis\Command\SetDifferenceStore"
          "SMEMBERS" => "Predis\Command\SetMembers"
          "SRANDMEMBER" => "Predis\Command\SetRandomMember"
          "ZADD" => "Predis\Command\ZSetAdd"
          "ZINCRBY" => "Predis\Command\ZSetIncrementBy"
          "ZREM" => "Predis\Command\ZSetRemove"
          "ZRANGE" => "Predis\Command\ZSetRange"
          "ZREVRANGE" => "Predis\Command\ZSetReverseRange"
          "ZRANGEBYSCORE" => "Predis\Command\ZSetRangeByScore"
          "ZCARD" => "Predis\Command\ZSetCardinality"
          "ZSCORE" => "Predis\Command\ZSetScore"
          "ZREMRANGEBYSCORE" => "Predis\Command\ZSetRemoveRangeByScore"
          "PING" => "Predis\Command\ConnectionPing"
          "AUTH" => "Predis\Command\ConnectionAuth"
          "SELECT" => "Predis\Command\ConnectionSelect"
          "ECHO" => "Predis\Command\ConnectionEcho"
          "QUIT" => "Predis\Command\ConnectionQuit"
          "INFO" => "Predis\Command\ServerInfoV26x"
          "SLAVEOF" => "Predis\Command\ServerSlaveOf"
          "MONITOR" => "Predis\Command\ServerMonitor"
          "DBSIZE" => "Predis\Command\ServerDatabaseSize"
          "FLUSHDB" => "Predis\Command\ServerFlushDatabase"
          "FLUSHALL" => "Predis\Command\ServerFlushAll"
          "SAVE" => "Predis\Command\ServerSave"
          "BGSAVE" => "Predis\Command\ServerBackgroundSave"
          "LASTSAVE" => "Predis\Command\ServerLastSave"
          "SHUTDOWN" => "Predis\Command\ServerShutdown"
          "BGREWRITEAOF" => "Predis\Command\ServerBackgroundRewriteAOF"
          "SETEX" => "Predis\Command\StringSetExpire"
          "APPEND" => "Predis\Command\StringAppend"
          "SUBSTR" => "Predis\Command\StringSubstr"
          "BLPOP" => "Predis\Command\ListPopFirstBlocking"
          "BRPOP" => "Predis\Command\ListPopLastBlocking"
          "ZUNIONSTORE" => "Predis\Command\ZSetUnionStore"
          "ZINTERSTORE" => "Predis\Command\ZSetIntersectionStore"
          "ZCOUNT" => "Predis\Command\ZSetCount"
          "ZRANK" => "Predis\Command\ZSetRank"
          "ZREVRANK" => "Predis\Command\ZSetReverseRank"
          "ZREMRANGEBYRANK" => "Predis\Command\ZSetRemoveRangeByRank"
          "HSET" => "Predis\Command\HashSet"
          "HSETNX" => "Predis\Command\HashSetPreserve"
          "HMSET" => "Predis\Command\HashSetMultiple"
          "HINCRBY" => "Predis\Command\HashIncrementBy"
          "HGET" => "Predis\Command\HashGet"
          "HMGET" => "Predis\Command\HashGetMultiple"
          "HDEL" => "Predis\Command\HashDelete"
          "HEXISTS" => "Predis\Command\HashExists"
          "HLEN" => "Predis\Command\HashLength"
          "HKEYS" => "Predis\Command\HashKeys"
          "HVALS" => "Predis\Command\HashValues"
          "HGETALL" => "Predis\Command\HashGetAll"
          "MULTI" => "Predis\Command\TransactionMulti"
          "EXEC" => "Predis\Command\TransactionExec"
          "DISCARD" => "Predis\Command\TransactionDiscard"
          "SUBSCRIBE" => "Predis\Command\PubSubSubscribe"
          "UNSUBSCRIBE" => "Predis\Command\PubSubUnsubscribe"
          "PSUBSCRIBE" => "Predis\Command\PubSubSubscribeByPattern"
          "PUNSUBSCRIBE" => "Predis\Command\PubSubUnsubscribeByPattern"
          "PUBLISH" => "Predis\Command\PubSubPublish"
          "CONFIG" => "Predis\Command\ServerConfig"
          "PERSIST" => "Predis\Command\KeyPersist"
          "STRLEN" => "Predis\Command\StringStrlen"
          "SETRANGE" => "Predis\Command\StringSetRange"
          "GETRANGE" => "Predis\Command\StringGetRange"
          "SETBIT" => "Predis\Command\StringSetBit"
          "GETBIT" => "Predis\Command\StringGetBit"
          "RPUSHX" => "Predis\Command\ListPushTailX"
          "LPUSHX" => "Predis\Command\ListPushHeadX"
          "LINSERT" => "Predis\Command\ListInsert"
          "BRPOPLPUSH" => "Predis\Command\ListPopLastPushHeadBlocking"
          "ZREVRANGEBYSCORE" => "Predis\Command\ZSetReverseRangeByScore"
          "WATCH" => "Predis\Command\TransactionWatch"
          "UNWATCH" => "Predis\Command\TransactionUnwatch"
          "OBJECT" => "Predis\Command\ServerObject"
          "SLOWLOG" => "Predis\Command\ServerSlowlog"
          "CLIENT" => "Predis\Command\ServerClient"
          "PTTL" => "Predis\Command\KeyPreciseTimeToLive"
          "PEXPIRE" => "Predis\Command\KeyPreciseExpire"
          "PEXPIREAT" => "Predis\Command\KeyPreciseExpireAt"
          "MIGRATE" => "Predis\Command\KeyMigrate"
          "PSETEX" => "Predis\Command\StringPreciseSetExpire"
          "INCRBYFLOAT" => "Predis\Command\StringIncrementByFloat"
          "BITOP" => "Predis\Command\StringBitOp"
          "BITCOUNT" => "Predis\Command\StringBitCount"
          "HINCRBYFLOAT" => "Predis\Command\HashIncrementByFloat"
          "EVAL" => "Predis\Command\ServerEval"
          "EVALSHA" => "Predis\Command\ServerEvalSHA"
          "SCRIPT" => "Predis\Command\ServerScript"
          "TIME" => "Predis\Command\ServerTime"
          "SENTINEL" => "Predis\Command\ServerSentinel"
          "SCAN" => "Predis\Command\KeyScan"
          "BITPOS" => "Predis\Command\StringBitPos"
          "SSCAN" => "Predis\Command\SetScan"
          "ZSCAN" => "Predis\Command\ZSetScan"
          "ZLEXCOUNT" => "Predis\Command\ZSetLexCount"
          "ZRANGEBYLEX" => "Predis\Command\ZSetRangeByLex"
          "ZREMRANGEBYLEX" => "Predis\Command\ZSetRemoveRangeByLex"
          "ZREVRANGEBYLEX" => "Predis\Command\ZSetReverseRangeByLex"
          "HSCAN" => "Predis\Command\HashScan"
          "PUBSUB" => "Predis\Command\PubSubPubsub"
          "PFADD" => "Predis\Command\HyperLogLogAdd"
          "PFCOUNT" => "Predis\Command\HyperLogLogCount"
          "PFMERGE" => "Predis\Command\HyperLogLogMerge"
          "COMMAND" => "Predis\Command\ServerCommand"
          "HSTRLEN" => "Predis\Command\HashStringLength"
          "BITFIELD" => "Predis\Command\StringBitField"
          "GEOADD" => "Predis\Command\GeospatialGeoAdd"
          "GEOHASH" => "Predis\Command\GeospatialGeoHash"
          "GEOPOS" => "Predis\Command\GeospatialGeoPos"
          "GEODIST" => "Predis\Command\GeospatialGeoDist"
          "GEORADIUS" => "Predis\Command\GeospatialGeoRadius"
          "GEORADIUSBYMEMBER" => "Predis\Command\GeospatialGeoRadiusByMember"
        ]
        -processor: null
      }
    ]
    #handlers: array:6 [
      "cluster" => "Predis\Configuration\ClusterOption"
      "connections" => "Predis\Configuration\ConnectionFactoryOption"
      "exceptions" => "Predis\Configuration\ExceptionsOption"
      "prefix" => "Predis\Configuration\PrefixOption"
      "profile" => "Predis\Configuration\ProfileOption"
      "replication" => "Predis\Configuration\ReplicationOption"
    ]
  }
  -profile: Predis\Profile\RedisVersion320 {#812}
}

@ValeriiTsarov
Copy link

Does Client object have any isConnected() method or another way to check connection?
This is a very optimistic way to use Client in the next line after $redis->connect();.

@nimaamiri92
Copy link
Author

Does Client object have any isConnected() method or another way to check connection?
This is a very optimistic way to use Client in the next line after $redis->connect();.

Yes, it has and return Ture

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants