redis icon indicating copy to clipboard operation
redis copied to clipboard

Doc: Add RDB file format specification (rdb-spec.md)

Open moticless opened this issue 1 month ago • 6 comments

Adds rdb-spec.md documenting the RDB v12 file format. Currently, the format is only documented through C code, making it difficult for developers and third-party implementations to understand. This spec provides a centralized reference covering all types, opcodes, and encodings. Another option is to have this file at librdb repo.

moticless avatar Nov 10 '25 09:11 moticless

i don't see the benefit.. it's not detailed enough to be used as a spec (for someone to parse the file solely based on that). e.g. detailing the exact encoding of everything.

it does say that the authority is the source code, which is nice.

i'm not sure it'll really serve any purpose. i.e. one purpose it can serve is to provide some introduction to the format, before getting into more details reading the source, but i'm not sure there's enough text here to cover that. another purpose it can serve it to explain reasoning and nuances in the format (but maybe code comments in either rdb.h or rdb.c could serve that purpose better.

all in all, i don't mind adding it, and gradually improving as we go, but i think the risk of leaving it stale are greater (see our README.md describing the files structure and other code parts :facepalm: )

oranagra avatar Nov 10 '25 09:11 oranagra

@oranagra, i can move it to librdb repo and maintain it there if you have doubts.

moticless avatar Nov 10 '25 10:11 moticless

well, being here means it's the official documentation of the format in redis. and arguably librdb is the official parser (part of the redis org), so maybe there's no big difference... i suppose being documented closer to rdb.c is better.

i just doubt it's very useful in the current state (not detailed enough for spec, and maybe not verbal enough for an introduction), and i'm afraid it'll easily become stale.

bottom line, from my perspective you can proceed as you see fit.

oranagra avatar Nov 10 '25 10:11 oranagra

As a side note, our official RDB format specifications should cover all the Redis 8+ modules. We should also align on a single version number, of course.

LiorKogan avatar Nov 10 '25 12:11 LiorKogan

@moticless We have a RESP reference here with it's source here.

Maybe it would be a better fit to have RDB files documented near that?

collinfunk avatar Nov 10 '25 19:11 collinfunk

@moticless We have a RESP reference here with it's source here.

Maybe it would be a better fit to have RDB files documented near that?

@collinfunk, according to the Code-Doc-Entropy law the further the doc drifts from the code, the faster it rots.

moticless avatar Nov 10 '25 20:11 moticless