Uploaded image for project: 'Couchbase PHP client library'
  1. Couchbase PHP client library
  2. PCBC-886

SDK locking up when inside a forked process

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Major
    • 4.2.1
    • 4.0.0
    • extension
    • AlmaLinux 8.7 x86_64 php 8.1.12
      AlmaLinux 9.0 aarch64 php 8.1.12
    • 0

    Description

      I have found that the couchbase4 php extention locks up after a php process has been forked

      I have attached a snippet of code to show the lockup.

       

      #!/usr/bin/php
      <?php
      include __DIR__ . '/application/cli/environment.php'; // basically composer autoload 
       
      use \Couchbase\ClusterOptions;
      use \Couchbase\Cluster;
       
      $username         = 'username';
      $password         = 'password';
      $connectionString = 'couchbase://10.10.10.10';
       
      $clusterOpts = new ClusterOptions();
      $clusterOpts->credentials($username, $password);
       
      $couchbase  = new Cluster($connectionString, $clusterOpts);
      $bucket     = $couchbase->bucket('default');
      $collection = $bucket->defaultCollection();
       
      $result = $collection->upsert('test-key', [time(), 'some data']);
       
      $data = $collection->get('test-key')->content();
       
      print_r($data);
       
      $processId = pcntl_fork();
      if ($processId < 0) {
          // cleanup using posix_kill & pcntl_wait
          throw new RuntimeException('pcntl_fork failed.');
      } elseif ($processId === 0) {
          // WE ARE IN THE CHILD
          $clusterOpts = new ClusterOptions();
          $clusterOpts->credentials($username, $password);
       
          $couchbase  = new Cluster($connectionString, $clusterOpts);
          $bucket     = $couchbase->bucket('default');
          $collection = $bucket->defaultCollection();
       
          $data = $collection->get('test-key')->content(); // <-- locks up and never returns
       
          print_r($data);
      } else {
          // WE ARE IN THE PARENT
          echo "parent\r\n";
      } 

      Attachments

        Issue Links

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

          Activity

            People

              avsej Sergey Avseyev
              Steven Steven Lewis
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty