redis / redis/node-redis

Thrown stream error while uncorking

Open
#1,033 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
17.6k
Forks
2k
Avg merge
2d 3h
Merged PRs (30d)
40

Description

  • Version: node_redis 2.4.2 (in the process of upgrading to 2.5.3 just in case), redis 2.8.24 on elasticache
  • Platform: node 4.4.1 on centos 7 (in the process of upgrading to 4.4.2)
  • Description: Description of your issue, stack traces from errors and code that reproduces the issue

This is me blatantly cross-posting [https://github.com/nodejs/node/issues/6154](this node core issue) because I don't actually know that it's their fault.

I have some production services that are throwing a pretty crazy error:

TypeError: Cannot set property 'entry' of null
    at clearBuffer (_stream_writable.js:379:18)
    at Socket.Writable.uncork (_stream_writable.js:238:7)
    at RedisClient.uncork (/cn/runtime/epi-services/nodejs/releases/current/node_modules/@condenast/tsugu-service/node_modules/redis/index.js:361:25)
    at Multi.exec_transaction (/cn/runtime/epi-services/nodejs/releases/current/node_modules/@condenast/tsugu-service/node_modules/redis/index.js:1171:18)

For some background: We're using redis as a caching layer, and this code is getting triggered while writing to redis with its 'multi' helper. We're using v2.4.2 of the redis module but I'm gonna upgrade to 2.5.3 just in case it helps.

As far as I can tell, what's happening here is that the redis client creates a net stream and at various points in time might call uncork on it, including inside the multi exec handler. For some reason, only sometimes, when this happens, trying to clear the buffer throws because state.corkedRequestsFree is null.

I did look at net and Duplex code paths, as well as the redis code, and didn't see anything touching internal stream state, but maybe I missed something?

Unfortunately, I don't have a reproducing case beyond the production code. I tried triggering this with a naive fuzzer on a writable stream, no dice.

Thanks!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing redis/index.js v2.4.2 around the net stream setup and Multi.exec transaction uncorking with Node's lib/_stream_writable.js around clearBuffer and the reported corkedRequestsFree access. Reproduce the failure if possible using the multi helper and Redis, then establish that the uncork path completes without throwing under the affected conditions.

Written by the indexing model from the issue text.

Assessment

Tech stack
nodejs, redis
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.