-
-
Notifications
You must be signed in to change notification settings - Fork 458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BinaryFormatter persistent version conflict #109
Comments
I will check if I can reproduce that somehow easily. Not sure if that's actually a real issue though. |
Here's how you can reproduce this easily:
I did just use JSON, I opened the issue to warn you that you ship with broken defaults. I guess that if you can't find a reason to recommend BinaryFormatter serialization to anyone, you should consider changing the default to JSON - it's probably the least intrusive of the available options. If nothing else, this issue could save some time for those that run into this problem, since what gets logged isn't very helpful in diagnosing it. Also, moving the discussion away from serialization, I'm curios why this approach to optimistic concurrency was chosen. What benefits does ferrying the data around have vs just using some random token for versioning? |
@CezarCretu I meant, reproducing it via unit testing ;) The issue how to do it in general is clear. Regarding your last point, I actually did an implementation with a versioning token, simple counter of some kind. That totally works, the concurrency model doesn't change though and it turned out, for small amount of data, the performance actually gets slightly worse. Thanks anyways for testing all that stuff! |
Sure, programatically triggering ths is probably more effort than it's worth, seeing that you'd have to create a very specific test for it, and the issue will only reproduce under a very predictable set of circumstances. Regarding logging, I don't think there's anything you can do, without looking for this exact issue. After all, it was telling me exactly what was going wrong, but my assumptions about what it was doing were preventing me from discovering the source of the problem. You do mention that you don't want to reference a json serializer in the core packages, but also that the .net core version doesn't come with one at all. I think that nothing is as good of a default as anything, certainly better than using There are ways in which to fix |
Just FYI: |
@CezarCretu I've changed the update mechanism in the redis handle to use a version field, seems to work pretty good and should fix your issue. Will be in the next release |
When using CacheManager with redis, the default serialization method is
BinaryFormatter
.Binary formatter includes the versioned assembly name into its binary output (see here).
Due to this, if you cache some non-primitive value referenced in an assembly, and then change that assembly's version, CacheManager won't be able to solve version conflicts on its own.
From my understanding of the code, on update it pulls the old value and deserializes it, which works fine. Then the output gets serialized again for comparison with the value stored in cache, and this is where the problem arises.
Since the version is included in the
BinaryFormatter
output, the comparison will always fail since the binary array will never be the same.The text was updated successfully, but these errors were encountered: