GithubHelp home page GithubHelp logo

Comments (10)

SebastianStehle avatar SebastianStehle commented on June 12, 2024 2

Yes, you are right. I should have read it more carefully. I think your observations are correct:

  1. Not every RedisServerException is a migration problem.
  2. Transactions are useless here.
  3. Delete should not be used.
  4. For migrations the key should just be overriden.

from orleans.redis.

jarkkojasberg avatar jarkkojasberg commented on June 12, 2024 2

Also lua script for write command should be loaded again to Redis server when RedisServerException with NOSCRIPT message is received.

The script cache is cleared when Redis server restarts. Lua script for write operation is initialized only in RedisGrainStorage.Init function. This means that application using this library is throwing RedisServerException with NOSCRIPT message until it is also restarted, because RedisGrainStorage.Init is only called when application starts.

Eval command documentation mentions that script cache is cleared in restart:
https://redis.io/commands/eval

Article that explains this issue:
http://www.wjwh.eu/posts/2020-06-15-redis-eval-trick.html

from orleans.redis.

jarkkojasberg avatar jarkkojasberg commented on June 12, 2024

Here is a graph that shows redis key count and how keys are deleted gradually after reboot.

redis_key_counts

from orleans.redis.

SebastianStehle avatar SebastianStehle commented on June 12, 2024

I think this is the default for redis. You have to turn on disk persistence

from orleans.redis.

jarkkojasberg avatar jarkkojasberg commented on June 12, 2024

We have configured RDB persistence for Redis server and also tested that data is restored from snapshot after reboot. If the persistence didn't work we should have lost all keys immediately when server was rebooted. Now keys were deleted gradually after reboot. I'm quite sure that the migration code in RedisGrainStorage.WriteStateAsync function is deleting keys from Redis server.

from orleans.redis.

ReubenBond avatar ReubenBond commented on June 12, 2024

Are you able to take a look at fixing this, @jarkkojasberg?

from orleans.redis.

jarkkojasberg avatar jarkkojasberg commented on June 12, 2024

@ReubenBond I have been quite busy lately, I can't promise fixing this anytime soon.

from orleans.redis.

f-i-x-7 avatar f-i-x-7 commented on June 12, 2024

Recently our team encountered same issue with permanent receival of exception as @jarkkojasberg mentioned in 1st post until Orleans silo was restarted. Most probably the reason was Redis server restart too (I didn't perform a deep investigation). We have .RDB persistence enabled too. Fortunately, this was a test environment.
May be I will be able to prepare suggested fix. But I did not see any contributing guidelines in this repo. If there are any, please let me know.

from orleans.redis.

f-i-x-7 avatar f-i-x-7 commented on June 12, 2024

Hello again,

As our team uses Orleans in production and we possibly will migrate some grains from ADO.NET/EF storage to Redis next year, we want to be sure in stable work of RedisGrainStorage. So one of my colleagues is going to fix this bug.

After discussion with him I've checked the code in RedisGrainStorage more carefully. It seems that migration logic from WriteStateAsync() can be safely removed because of 2 reasons:

  1. Every grain at first reads state from storage. So if migration needed, it would be already performed duringReadStateAsync() call.
  2. Migration logic in WriteStateAsync(), if executed, actually would fail. It uses the same Lua script as regular WriteStateAsync() operation. This script uses HGET command to retrieve Palyload and ETag. But for old grain storage format HGET would throw (something like "(error) ERR Error running script (call to f_6b1bf486c81ceb7edf3c093f4c48582e38c0e791): ERR Operation against a key holding the wrong kind of value").

So, as part of the bugfix, we are going just to remove migration logic from WriteStateAsync().

@ReubenBond @SebastianStehle are you OK with that?

from orleans.redis.

f-i-x-7 avatar f-i-x-7 commented on June 12, 2024

It seems that migration logic from WriteStateAsync() can be safely removed

Well, actually after deletion of migration logic from WriteStateAsync() one test failed. So I decided to fix migration logic in WriteStateAsync() - do not use Lua script but execute same commands within transaction as migration in ReadStateAsync() does.

BTW:

Yes, you are right. I should have read it more carefully. I think your observations are correct:

  1. Not every RedisServerException is a migration problem.
  2. Transactions are useless here.
  3. Delete should not be used.
  4. For migrations the key should just be overriden.

Actually delete MUST be used, because string key in Redis cannot be overwritten by hash. So IMHO it is OK to stick with transactions as of now (other option is to switch to another Lua scripts, but it will bring additional complexity related with handling of NOSCRIPT errors, etc.).

What about 1st point - "Not every RedisServerException is a migration problem." - I've added some checks to decide whether migration is required.

from orleans.redis.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.