fixed race condition in recording, Recording file is now moved, inste…#200
Conversation
|
During my tests I got the following exception:
|
|
Another issue appeared during load testing:
Both issues seem to be extremely rare, still they point to concurrency problems in the recorder. |
|
@hrosa right. do you have any ideas when the different methods on recorder are called? I mean would be really good to know if the fix shall be proper. |
|
I think this is because you still have cleanup logic in the checkIn() method. without much analysis, I can tell you
I was naive enough to believe it was safe to implement checkIn method and do cleanup there, believing that since object is being put back into the pool then it was not being used anymore. Another problem i noticed during my load tests (wrt recording use case) is that the resulting files tend to decrease in size sometimes. Recording quality is good though. |
|
Couple of notes:
We need to solidify concurrent operations in recorder taking into account these factors. |
|
@hrosa will review today, and see how this can be done. |
|
@hrosa My first thought would be to just toss away any Recorder once used. That way we can prevent anything to happen after Recorder is deactivated. If that isn't the solution, then I think only issue we have there is that we have to guarantee to As you suggest, we will have the cleanup code only on one place (I remove that checkin check). Furthermore I am thinking to introduce an AtomicRef to guard about perhaps multiple concurrent invocations of the deactivate code. Any thoughts? Suggestions? |
|
@hrosa just pushed the update. This is sort of re-work, and I believe shall be correct and safe for now. (At least cannot think of scenarios where concurrent invocations of deactivate or checkin will mess. I have introduced the Sink, that is tossed away with each deactivate call and created when the file is set. Also this guarantees, that there cannot be write operations while the sink is making its commit, in case there were some leftover references writing to the recorder. I run 10k call through it and no issue. lmk what do you think |
…ng-fix-2 # Conflicts: # resources/recorder/src/main/java/org/mobicents/media/server/impl/resource/audio/AudioRecorderImpl.java
|
nicely done @pchlupacek thank you! |

as discussed in #128