Uploaded image for project: 'PHP Legacy Driver'
  1. PHP Legacy Driver
  2. PHP-1516

MongoGridFSFile->getBytes() error reading chunk of file

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Won't Fix
    • Affects Version/s: 1.6.14
    • Fix Version/s: None
    • Component/s: pecl-mongo
    • Labels:
      None
    • # Replies:
      1
    • Last comment by Customer:
      true

      Description

      After storing a file to gridfs and accessing it directly afterwards, I sometimes get this:

      Exception: "error reading chunk of file"

      after calling "MongoGridFSFile::getBytes()"

      I thought this is perhaps a concurrency issue and tried the following:

              $gridFs->storeBytes(
                  serialize($snapshot->aggregateRoot()),
                  [
                      'aggregate_type' => $snapshot->aggregateType()->toString(),
                      'aggregate_id' => $snapshot->aggregateId(),
                      'last_version' => $snapshot->lastVersion(),
                      'created_at' => $createdAt,
                      'transaction_id' => $transactionId,
                  ],
                  $this->writeConcern
              );
       
              $gridFs->update(
                  [
                      'transaction_id' => $transactionId
                  ],
                  [
                      '$unset' => [
                          'transaction_id' => true
                      ]
                  ],
                  $this->writeConcern
              );
      

      And during get:

              $gridFsfile = $gridFs->findOne(
                  [
                      '$query' => [
                          'aggregate_type' => $aggregateType->toString(),
                          'aggregate_id' => $aggregateId,
                          'transaction_id' => [
                              '$exists' => false,
                          ]
                      ],
                      '$orderBy' => [
                          'last_version' => -1,
                      ],
                  ]
              );
      

      But having the transaction_id in place does not solve the problem. Now i'm stuck. When I try to access the file, after I received this error, it's no problem and the file is there!

        Attachments

          Activity

            People

            • Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since reply:
                3 years, 16 weeks ago
                Date of 1st Reply: