Details

    • Type: Bug
    • Status: Resolved
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 1.1.0-dp1, 1.1.0-dp2
    • Fix Version/s: None
    • Component/s: library
    • Security Level: Public
    • Labels:
      None

      Description

      Zlib compression is broken. This means large payloads are never compressed on the network.

      class Compression extends CouchbaseTestCommon {
      function testCompression() {

      if (!extension_loaded('zlib'))

      { $this->markTestSkipped("Need Zlib extension"); }

      $h = make_handle();
      $hnc = make_handle();

      $curcomp = couchbase_get_option($h, COUCHBASE_OPT_COMPRESSION);
      $this->assertEquals(COUCHBASE::COMPRESSION_NONE, $curcomp);

      couchbase_set_option($h, COUCHBASE_OPT_COMPRESSION,
      COUCHBASE::COMPRESSION_ZLIB);
      $curcomp = couchbase_get_option($h, COUCHBASE_OPT_COMPRESSION);
      $this->assertEquals(COUCHBASE_COMPRESSION_ZLIB, $curcomp);

      couchbase_set_option($hnc, COUCHBASE_OPT_COMPRESSION,
      COUCHBASE::COMPRESSION_NONE);

      $inikey = "couchbase.compression_threshold";
      $this->assertGreaterThan(0, ini_get($inikey));
      $this->assertTrue((bool)ini_alter($inikey,"10"));
      $this->assertEquals(10, ini_get($inikey));

      1. Set a compressed value
        $v = str_repeat("long_value", 500);
        $ol = strlen($v);
        //$key = $this->mk_key();
        $key = "compressed_data";

      $rv = couchbase_set($h, $key, $v);
      $this->assertNotEmpty($rv);

      $comp = couchbase_get_option($h, COUCHBASE_OPT_COMPRESSION);
      print $comp . "\n";

      1. Hack, append resets the flags, clearing the compression state.
        $rv = couchbase_append($hnc, $key, '_');
        $this->assertNotEmpty($rv);

      $ret = couchbase_get($hnc, $key);
      $this->assertNotNull($ret);
      $this->assertLessThan($ol, strlen($ret));
      }
      }

      No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

        Hide
        mnunberg Mark Nunberg added a comment -

        Apparently this results in (silent) memory corruption as well.. leading to unpredictable results. A similar test (pasted below) gives me this:

        PHP Warning: PHP Startup: Unable to load dynamic library '/home/mnunberg/src/php-ext-couchbase-1.0.x/modules/pdo.so' - /home/mnunberg/src/php-ext-couchbase-1.0.x/modules/pdo.so: cannot open shared object file: No such file or directory in Unknown on line 0
        PHPUnit 3.6.12 by Sebastian Bergmann.

        PHP Fatal error: Out of memory (allocated 3145728) (tried to allocate 4992063506150606153 bytes) in /home/mnunberg/src/php-couchbase-tests/unit/Compression.php on line 54
        PHP Stack trace:
        PHP 1.

        {main}

        () /usr/bin/phpunit:0
        PHP 2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:46
        PHP 3. PHPUnit_TextUI_Command->run() /usr/share/php/PHPUnit/TextUI/Command.php:130
        PHP 4. PHPUnit_TextUI_TestRunner->doRun() /usr/share/php/PHPUnit/TextUI/Command.php:192
        PHP 5. PHPUnit_Framework_TestSuite->run() /usr/share/php/PHPUnit/TextUI/TestRunner.php:325
        PHP 6. PHPUnit_Framework_TestSuite->runTest() /usr/share/php/PHPUnit/Framework/TestSuite.php:745
        PHP 7. PHPUnit_Framework_TestCase->run() /usr/share/php/PHPUnit/Framework/TestSuite.php:772
        PHP 8. PHPUnit_Framework_TestResult->run() /usr/share/php/PHPUnit/Framework/TestCase.php:751
        PHP 9. PHPUnit_Framework_TestCase->runBare() /usr/share/php/PHPUnit/Framework/TestResult.php:649
        PHP 10. PHPUnit_Framework_TestCase->runTest() /usr/share/php/PHPUnit/Framework/TestCase.php:804
        PHP 11. ReflectionMethod->invokeArgs() /usr/share/php/PHPUnit/Framework/TestCase.php:942
        PHP 12. Compression->testCompression() /usr/share/php/PHPUnit/Framework/TestCase.php:942
        PHP 13. couchbase_get() /home/mnunberg/src/php-couchbase-tests/unit/Compression.php:54
        couchbase_50493659660c9

        Show
        mnunberg Mark Nunberg added a comment - Apparently this results in (silent) memory corruption as well.. leading to unpredictable results. A similar test (pasted below) gives me this: PHP Warning: PHP Startup: Unable to load dynamic library '/home/mnunberg/src/php-ext-couchbase-1.0.x/modules/pdo.so' - /home/mnunberg/src/php-ext-couchbase-1.0.x/modules/pdo.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHPUnit 3.6.12 by Sebastian Bergmann. PHP Fatal error: Out of memory (allocated 3145728) (tried to allocate 4992063506150606153 bytes) in /home/mnunberg/src/php-couchbase-tests/unit/Compression.php on line 54 PHP Stack trace: PHP 1. {main} () /usr/bin/phpunit:0 PHP 2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:46 PHP 3. PHPUnit_TextUI_Command->run() /usr/share/php/PHPUnit/TextUI/Command.php:130 PHP 4. PHPUnit_TextUI_TestRunner->doRun() /usr/share/php/PHPUnit/TextUI/Command.php:192 PHP 5. PHPUnit_Framework_TestSuite->run() /usr/share/php/PHPUnit/TextUI/TestRunner.php:325 PHP 6. PHPUnit_Framework_TestSuite->runTest() /usr/share/php/PHPUnit/Framework/TestSuite.php:745 PHP 7. PHPUnit_Framework_TestCase->run() /usr/share/php/PHPUnit/Framework/TestSuite.php:772 PHP 8. PHPUnit_Framework_TestResult->run() /usr/share/php/PHPUnit/Framework/TestCase.php:751 PHP 9. PHPUnit_Framework_TestCase->runBare() /usr/share/php/PHPUnit/Framework/TestResult.php:649 PHP 10. PHPUnit_Framework_TestCase->runTest() /usr/share/php/PHPUnit/Framework/TestCase.php:804 PHP 11. ReflectionMethod->invokeArgs() /usr/share/php/PHPUnit/Framework/TestCase.php:942 PHP 12. Compression->testCompression() /usr/share/php/PHPUnit/Framework/TestCase.php:942 PHP 13. couchbase_get() /home/mnunberg/src/php-couchbase-tests/unit/Compression.php:54 couchbase_50493659660c9
        Hide
        mnunberg Mark Nunberg added a comment -

        The problem reaches far deeper than simple zlib.

        The compression headers themselves (the client uses a non-standard header, rather than gzip) is specified as a 'size_t', therefore this will break for any communication between cross-architecture clients.. i.e. i386 clients will not be able to properly encode lengths for x86_64 clients.

        Additionally, 'simple' zlib compression won't work either because of said header.

        Show
        mnunberg Mark Nunberg added a comment - The problem reaches far deeper than simple zlib. The compression headers themselves (the client uses a non-standard header, rather than gzip) is specified as a 'size_t', therefore this will break for any communication between cross-architecture clients.. i.e. i386 clients will not be able to properly encode lengths for x86_64 clients. Additionally, 'simple' zlib compression won't work either because of said header.
        Show
        mnunberg Mark Nunberg added a comment - http://review.couchbase.org/#/c/20604/

          People

          • Assignee:
            mnunberg Mark Nunberg
            Reporter:
            mnunberg Mark Nunberg
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Gerrit Reviews

              There are no open Gerrit changes