Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.6
    • Component/s: PHP - Library
    • Labels:
      None
    • Environment:

      Fedora 8, 64bit, php 5.2.4

    • Patch Info:
      Patch Available

      Description

      I'm working with the Hive thrift service and I get the following exception when I execute a SELECT statement:

      PHP Fatal error: Uncaught exception 'TException' with message 'TSocket: timed out reading 4 bytes from localhost:10000' in /root/leap/dev/servers/hive/thriftroot/
      transport/TSocket.php:228
      Stack trace:
      #0 /root/leap/dev/servers/hive/thriftroot/protocol/TBinaryProtocol.php(292): TSocket->readAll(4)
      #1 /root/leap/dev/servers/hive/thriftroot/protocol/TBinaryProtocol.php(184): TBinaryProtocol->readI32(NULL)
      #2 /root/leap/dev/servers/hive/thriftroot/packages/hive_service/ThriftHive.php(59): TBinaryProtocol->readMessageBegin(NULL, 0, 0)
      #3 /root/leap/dev/servers/hive/thriftroot/packages/hive_service/ThriftHive.php(28): ThriftHiveClient->recv_execute()
      #4 /root/leap/dev/servers/hive/testscript.php(30): ThriftHiveClient->execute('SELECT num FROM...')
      #5

      {main}

      thrown in /root/leap/dev/servers/hive/thriftroot/transport/TSocket.php on line 228

      The script I'm using to cause this is:

      ======================================
      #!/usr/bin/php
      <?php

      $GLOBALS['THRIFT_ROOT'] = 'thriftroot/';

      require_once $GLOBALS['THRIFT_ROOT'] . 'packages/hive_service/ThriftHive.php';
      require_once $GLOBALS['THRIFT_ROOT'] . 'transport/TSocket.php';
      require_once $GLOBALS['THRIFT_ROOT'] . 'protocol/TBinaryProtocol.php';

      $transport = new TSocket('localhost', 10000);
      $protocol = new TBinaryProtocol($transport);
      $client = new ThriftHiveClient($protocol);
      $transport->open();

      try

      { $client->execute('DROP TABLE testOverThrift'); }

      catch (Exception $e)

      { error_log("Got exception while trying to drop table: " . $e->getMessage()); }

      $client->execute('CREATE TABLE testOverThrift (num int)');

      $client->execute('LOAD DATA LOCAL
      INPATH "/root/testdata.txt"
      INTO TABLE testOverThrift');

      $client->execute('SELECT num FROM testOverThrift WHERE num < 5');

      $result = $client->fetchAll();

      var_dump($result);
      ==================================

      I have a patch that fixes the problem that I'll attach. It looks like fetchAll() doesn't know the difference between a timeout and a blocking port.

      1. thrift-347-0.5.0.txt
        2 kB
        Tyler Hobbs
      2. TSocket.php.diff
        0.8 kB
        Gary Richardson
      3. TSocket.php.patch
        1.0 kB
        Takuya Watabe

        Issue Links

          Activity

          Gary Richardson created issue -
          Gary Richardson made changes -
          Field Original Value New Value
          Attachment TSocket.php.diff [ 12400800 ]
          Eric Lam made changes -
          Comment [ I ran into a very similar issue but this issue seems related to the result of strlen($buf) is different from the size actually read.

          I tried to read the number of bytes read by ftell before and after fread

          $curr = @ftell($this->handle_);
          $buf = @fread($this->handle_, $len)
          $next = @ftell($this->handle_);

          $nread = $next - $curr;

          However, $nread is not equal to strlen($buf) and $nread is the number of bytes I expected to receive.


          ]
          Takuya Watabe made changes -
          Attachment TSocket.php.patch [ 12456804 ]
          Takuya Watabe made changes -
          Attachment TSocket.php.patch [ 12456804 ]
          Takuya Watabe made changes -
          Attachment TSocket.php.patch [ 12456805 ]
          Tyler Hobbs made changes -
          Attachment thrift-347-0.5.0.txt [ 12459833 ]
          T Jake Luciani made changes -
          Fix Version/s 0.6 [ 12315359 ]
          Bryan Duxbury made changes -
          Status Open [ 1 ] Closed [ 6 ]
          Assignee Tyler Hobbs [ thobbs ]
          Resolution Fixed [ 1 ]
          Jens Geyer made changes -
          Link This issue is superceded by THRIFT-638 [ THRIFT-638 ]

            People

            • Assignee:
              Tyler Hobbs
              Reporter:
              Gary Richardson
            • Votes:
              2 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development