-
Notifications
You must be signed in to change notification settings - Fork 23.8k
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
Add timestamp annotations in AOF #9326
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems a bit odd that we'll merge this when we don't yet do anything with it.
maybe we should improve aof-check with some feature to truncate the AOF after a certain time?
or add a feature for redis in which it stops the loading when reaching a certain time? (so you don't need to process a huge aof file twice)
Yes, we should provide tool or support to restore data to a specific time.
Initially, i also want to do this, but there are some worries. First, The config of stop time is dangerous, redis may only load old data if we keep this config in config file. And users usually download backup AOF and reload to specific time for special purposes , and we also face there are some scenarios, no timestamps or not finding specific timestamp in AOF, it is not appropriate to directly do something without asking opinions of users or corresponding configs. |
@redis/core-team please approve the concept, new config option, and new redis-check-aof feature. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Co-authored-by: Itamar Haber <itamar@redis.com>
* | ||
* Timestamp annotation format is "#TS:${timestamp}\r\n". "TS" is short of | ||
* timestamp and this method could save extra bytes in AOF. */ | ||
sds genAofTimestampAnnotationIfNeeded(int force) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will the annotations generally be of the format: #{name}:{value}\r\n ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also forgive my ignorance about AOF, but I thought it generally followed the RESP protocol, so instead should we use the attribute type notation from RESP3 which describes a similar syntax.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @madolson the format: #{name}:{value}\r\n is only one of annotations, the format is loose #9325.
Initially, i want to use a special command to identify annotations, but AOF is the set of write commands, so it will be odd, maybe we even add one more command for annotations, so i abandon.
The attribute type of RESP3 can represent notation, but i think it is for reply, i am not sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was reading this comment:
AOF (Append Only File): The AOF persistence logs every write operation received by the server, that will be played again at server startup, reconstructing the original dataset. Commands are logged using the same format as the Redis protocol itself, in an append-only fashion. Redis is able to rewrite the log in the background when it gets too big.
So if someone was tailing it, they could use a RESP parser to understand what was going on. Maybe that is a dumb comment and someone that runs a lot of AOF systems can tell me otherwise, I just wanted to mention it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't think we must look too much into that comment.
i think it is ok for the annotations to be AOF "comments" and not use RESP3 attributes.
First because AOF is indeed requests (which aren't actually using RESP3, just multi-bulks), and secondly, even if requests in the future will be using attributes, maybe we don't want to collide with them.
i.e. the annotations are (for now) generic comments about the AOF, and not explicitly referring to the immediate request that follows (next command).
so this actually raises another problem. what if AOF file will in the future wanna use the RESP3 booleans? (which use #
)
maybe, just to be on the safe side, we should chose another character? or use two ##
instead of one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think -
should be safe, even in a future where we accept RESP3 formatted commands it's not likely that clients will be sending errors to servers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we use RESP3 in AOF, maybe timestamp looks like that. But it brings much complexity for processMultibulkBuffer
. i am not sure we will support in the future.
*3
|1
+ts
:1632711499
$3
set
$1
a
$1
b
The reason why I use #
is that #
is some languages' annotation. Currently, RESP3 already used many normal characters. i have no idea which character to use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use / instead? Kind of like a comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/
is a comment? you're referring to //
?
I feel this discussion is a dead end.. let's stick to #
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @oranagra for your merging unstable branch
even we accept RESP3 formatted commands, we just support some RESP3 fields in multi-bulks
, right? So i think annotation prefix(#
, one character just is different from *
) doesn't do harm since we do parse based on some context.
We need to push it forward, if we don't strongly oppose #
, i think we can adopt it.
For AOF annotations, maybe we could support some descriptions that are similar with RDB AUX fields if needed, such as version(when we add new data type, change it), module info, memory usage...
Fix timing issue of a new test introduced in #9326
Add timestamp annotation in AOF, one part of #9325.
Enabled with the new
aof-timestamp-enabled
config option.Timestamp annotation format is "#TS:${timestamp}\r\n"."
TS" is short of timestamp and this method could save extra bytes in AOF.
We can use timestamp annotation for some special functions.