Skip to content
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

client is closed error #7

Open
fco-fbatch opened this issue May 2, 2023 · 7 comments
Open

client is closed error #7

fco-fbatch opened this issue May 2, 2023 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@fco-fbatch
Copy link
Member

Getting client is closed error while trying to use the latest version.

@erhant you can check the code I am getting an error here. And my redisClient and hollowdb creation process is here.

The error I am getting

/home/fco/Documents/GitHub/hollowdb-crud-microservices/get-service/node_modules/@redis/client/dist/lib/client/index.js:490
        return Promise.reject(new errors_1.ClientClosedError());
                              ^

ClientClosedError: The client is closed
    at RedisClient._RedisClient_sendCommand (/home/fco/Documents/GitHub/hollowdb-crud-microservices/get-service/node_modules/@redis/client/dist/lib/client/index.js:490:31)
    at RedisClient.commandsExecutor (/home/fco/Documents/GitHub/hollowdb-crud-microservices/get-service/node_modules/@redis/client/dist/lib/client/index.js:188:154)
    at BaseClass.<computed> [as SET] (/home/fco/Documents/GitHub/hollowdb-crud-microservices/get-service/node_modules/@redis/client/dist/lib/commander.js:8:29)
    at RedisCache.put (/home/fco/Documents/GitHub/hollowdb-crud-microservices/get-service/node_modules/warp-contracts-redis/lib/cjs/redisCache.js:277:31)
    at CacheableStateEvaluator.putInCache (/home/fco/Documents/GitHub/hollowdb-crud-microservices/get-service/node_modules/warp-contracts/lib/cjs/core/modules/impl/CacheableStateEvaluator.js:126:26)
    at CacheableStateEvaluator.onStateEvaluated (/home/fco/Documents/GitHub/hollowdb-crud-microservices/get-service/node_modules/warp-contracts/lib/cjs/core/modules/impl/CacheableStateEvaluator.js:67:20)
    at CacheableStateEvaluator.doReadState (/home/fco/Documents/GitHub/hollowdb-crud-microservices/get-service/node_modules/warp-contracts/lib/cjs/core/modules/impl/DefaultStateEvaluator.js:244:24)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async CacheableStateEvaluator.eval (/home/fco/Documents/GitHub/hollowdb-crud-microservices/get-service/node_modules/warp-contracts/lib/cjs/core/modules/impl/CacheableStateEvaluator.js:62:16)
    at async HandlerBasedContract.readState (/home/fco/Documents/GitHub/hollowdb-crud-microservices/get-service/node_modules/warp-contracts/lib/cjs/contract/HandlerBasedContract.js:121:28)

Node.js v18.12.1
error Command failed with exit code 1.
@fco-fbatch fco-fbatch added the bug Something isn't working label May 2, 2023
@fco-fbatch
Copy link
Member Author

Bonus explenation,

If I try to manually call connect() before the hollowdb.readState(), either by directly using redisClient or using the redisClient by underlying storage() method, I am getting the connection is already opened error.

If I omit using connect() I get The client is closed error.

@erhant
Copy link
Member

erhant commented May 2, 2023

Apparently, just using useKVStorageFactory alone does not produce this error, but using multiple cache options (useStateCache and useContractCache) do cause it.

@fco-fbatch
Copy link
Member Author

fco-fbatch commented May 3, 2023

As a solution, I am offering adding a separate opt isManaged when creating the RedisCache. If isManaged is true then the underlying warp instance cannot close or open connections to redis only the caller can. You can check this branch for the proposed changes. I also changed the redisClientType.

@erhant
Copy link
Member

erhant commented May 3, 2023

#8 introduces this temporary fix, along with major changes to the code. now, the client is created within the cache as is the case in LMDB.

@erhant
Copy link
Member

erhant commented May 3, 2023

@fco-fbatch the recent pull seems to fix the error, without the workaround!
still not closing this as we need further testing

@erhant erhant self-assigned this May 3, 2023
@erhant
Copy link
Member

erhant commented May 16, 2023

#9 now allows client to be added from outside, which internally makes isManaged = true and expects the clilent to make open and close calls.

@erhant
Copy link
Member

erhant commented Jul 4, 2023

probably should be mentioned, the other SortKeyCache implementations are targeted for local environments (as per the lazy-evaluation on client-side requirements) however Redis cache aims to provide a single online cache for multiple clients.

This may be the root cause of open and close bugs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants