Question

I'm using MongoDB driver in C#, and store video files using GridFS.
I store the files continuously like recording a stream and once in a while (might be in middle of writing process) I ask to "play" a file.
In some cases, at that part of playing the file there's a problem:
1. the relevant GridFS file stream is opened.
2. data read ok.
3. GridFS file stream is closed -> throws WriteConcernException with the following details:

WriteConcern detected an error 'E11000 duplicate key error index:
ElSightRecs.fs.chunks.$files_id_1_n_1  dup key: { :
ObjectId('536243c4c449203a24a8f3b2'), : 2656 }'. 
(Response was { "err" : "E11000 duplicate key error index: 
ElSightRecs.fs.chunks.$files_id_1_n_1  dup key: { : 
ObjectId('536243c4c449203a24a8f3b2'), : 2656 }", "code" : 11000, "n" : 0,
"connectionId" : 1111, "ok" : 1.0 }).

`

why do i get any write error when all I'm doing is closing the file stream?

Was it helpful?

Solution

well, I'm not sure if it's a bug in MongoDB driver or not, but I've found the problem.
I opened the GridFS file with OpenRead() so I thought I'm well protected. apparently not.
I had a bug that called Seek to a position higher than the file length. this caused the closing problem...
don't know why, don't know who ... but maybe other could use this tip :)

OTHER TIPS

@RoeeK, the connection closing out may be intended behaviour for seek beyond the length of the file.

However I am concerned about the error that you are getting. Are you able to re-produce that with some smaller sample code? If so, can you please share that.

In your error snippet, were your reading / performing operation on file with _id = '536243c4c449203a24a8f3b2'?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top