Describe the bug

The Redis version 6.0.20 has a pipe fd leak issue

To reproduce

Step 1: Download and compile Redis Version 6.0.20

Step 2: Start two Redis instances on ports 6378 and 6379

Step 3: Write some data to the Redis instance on port 6379 redis-benchmark -r 1 -n 4000000 -r 10000000 set string__rand_int__ string__rand_int__

Step 5: Continuously execute the following command to observe the pipe fd leak on Redis Port 6379 redis-cli -p 6378 slaveof no one && redis-cli -p 6378 flushall && redis-cli -p 6378 slaveof 127.0.0.1 6379 && redis-cli -p 6379 bgsave

Step 6: Check for pipe fd leak by inspecting the /proc/pid/fd directory. As shown in the following image 581c8056-8119-4400-9bbb-13488114a996

Expected behavior

No pipe fd leak

Additional information After testing, this issue exists in both the 4.x and 5.x versions.

Comment From: 123alf

Upon reviewing the code of version 6.0.20, I found that the pipe(server.child_info_pipe) for the previous dump RDB operation was not released, and a new pipe(server.child_info_pipe) was created to execute the new dump RDB task. The problem stack is as follows

0 openChildInfoPipe () at childinfo.c:37

1 0x0000aaaaaab130c8 in rdbSaveBackground (filename=0xfffff783af60 "dump.rdb", rsi=0xffffffffee48) at rdb.c:1393

2 0x0000aaaaaab09318 in startBgsaveForReplication (mincapa=mincapa@entry=3) at replication.c:655

3 0x0000aaaaaab0a0c8 in updateSlavesWaitingBgsave (bgsaveerr=0, type=1) at replication.c:1305

4 0x0000aaaaaab15c44 in backgroundSaveDoneHandler (exitcode=, bysignal=bysignal@entry=0) at rdb.c:2525

5 0x0000aaaaaaae5e54 in checkChildrenDone () at server.c:1809

6 0x0000aaaaaaae94bc in serverCron (eventLoop=, id=, clientData=) at server.c:1980

7 0x0000aaaaaaadff08 in processTimeEvents (eventLoop=0xfffff780b480) at ae.c:357

8 aeProcessEvents (eventLoop=eventLoop@entry=0xfffff780b480, flags=flags@entry=27) at ae.c:509

9 0x0000aaaaaaae0974 in aeProcessEvents (flags=27, eventLoop=0xfffff780b480) at ae.c:391

10 aeMain (eventLoop=0xfffff780b480) at ae.c:539

11 0x0000aaaaaaadc89c in main (argc=1, argv=0xfffffffff368) at server.c:5536

Comment From: ShooterIT

could you try on latest branch? i remember we fix some issues about fd leak.

Comment From: 123alf

this issue is not found in version 6.2.16. thx.