doctrine / mongodb-odm

The Official PHP MongoDB ORM/ODM
https://www.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/
MIT License
1.09k stars 504 forks source link

Files are not stored in GridFS if fs.files and fs.chunks are not created. #2129

Closed blakyris closed 4 years ago

blakyris commented 4 years ago

Bug Report

Symfony version : 4.3 ODM Version : latest MongoDB : latest OS : WIndows 10 or Linux PHP : 7.2 / 7.3 PHP MongoDB Driver : 1.6

Summary

I'm storing a music collection in a Symfony project using MongoDB GridFS. I always delete database to be sure everything OK in my test env. I'm using MongoDB latest on Windows and Ubuntu (both native, not VM nor Docker or WSL...). MongoDB is a local instance with no credentials or anything fancy.

Current behavior

My app takes an audio file, reads ID3 tags and build an array of all track metadata. Then I'm storing the file, get the id of the file and link it to a Track in the Track collection. So I'm not storing the Track metadata in the FIle, but I'm storing the File id in the Track metadata collection. (that's not the issue because I've tested it.)

How to reproduce

To conclude, by my tests, the issus is :

When I delete the DB, I upload a file using uploadFromFile() function. fs.chunks and fs.files will be created but only chunks are stored and you have nothing in fs.files.

So you can create a DB with both collections : fs.files and fs.chunks in your DB and the file will be stored with its ref and the chunks.

malarzm commented 4 years ago

@blakyris how is this different from #2109?

blakyris commented 4 years ago

I've done some test to be sure it was a bug and I would like to be more precise on the behavior and what is the bug exactly.

malarzm commented 4 years ago

Would you be able to write a functional test in ODM like this one? This would greatly speed things up for us.

alcaeus commented 4 years ago

@blakyris In the future, don’t open a new report for the same issue. I previously asked you to create a reproducer because I could not reproduce the issue in tests, and you haven’t done so yet. Until you do, there’s nothing we can do here or in any other ticket you create.

blakyris commented 4 years ago

Ok I will make some tests for you to reproduce the issue.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in a week if no further activity occurs. Thank you for your contributions.

rrajkomar commented 1 month ago

Hi, @alcaeus I've actually stumbled on the same issue I believe.

Here's a scenario that triggers the issue every time :

With a freshly booted mongo instance run an uploadFile to the instance, the fs.chunks are correctly created but the fs.files entry is not.

Notes : In my case it was within a loop of 15 files being created by the fixture class but only the first file shows the issue and only if the mongodb instance is freshly booted. My mongo instance is in a docker container. If I simply run the fixtures a second time without rebooting the instance (completely from scratch, not just restart) everything works fine.