BGREWRITEAOF(3valkey)

πŸ“¦
version 9.0.6 Β· 2 versions
, in fedora 44

✨ BGREWRITEAOF ✨

ok so bestie, welcome to BGREWRITEAOF(3valkey) from the Valkey Command Manual β€” she's a classic, she's been here since forever, and she's about to make your Append Only File look ✨snatched✨.


πŸ’– NAME πŸ’–

bgrewriteaof β€” asynchronously rewrites the append-only file to disk. no cap, that's the whole job.


πŸŽ€ SYNOPSIS πŸŽ€

BGREWRITEAOF

that's it. no args. no flags. she's low maintenance fr.


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so you're telling Valkey to start an Append Only File rewrite process. what that actually does is create a small optimized version of the current Append Only File. like a glow-up but for your AOF. πŸ’…

and here's the comforting part: if BGREWRITEAOF fails, no data gets lost, because the old AOF is left completely untouched. she would never do you dirty like that. 🫢

the rewrite only gets triggered by Valkey if there isn't already a background process doing persistence. so basically she checks the room before she starts dancing. specifically:

  • If a Valkey child is creating a snapshot on disk, the AOF rewrite is scheduled but not started until the saving child producing the RDB file terminates. In this case the BGREWRITEAOF will still return a positive status reply, but with an appropriate message. You can check if an AOF rewrite is scheduled by looking at the valkey-info(7) INFO command. πŸ‘€
  • If an AOF rewrite is already in progress, the command returns an error and no AOF rewrite will be scheduled for a later time. not a "later bestie", just a no. πŸ’€
  • If the AOF rewrite could start, but the attempt at starting it fails (for instance because of an error in creating the child process), an error is returned to the caller.
ngl this is the important bit: the AOF rewrite is automatically triggered by Valkey on its own, BUT the BGREWRITEAOF command exists so you can trigger a rewrite at any time you want. main character energy, your call. πŸ‘‘

Please refer to the persistence documentation for detailed information. (yes, actually go read it, iykyk πŸ“š)


🌸 REPLY 🌸

πŸ’œ RESP2 πŸ’œ

valkey-protocol(7) Simple string reply: a simple string reply indicating that the rewriting started or is about to start ASAP when the call is executed with success.

The command may reply with an error in certain cases, as documented above.

🌈 RESP3 🌈

valkey-protocol(7) Bulk string reply: a simple string reply indicating that the rewriting started or is about to start ASAP when the call is executed with success.

The command may reply with an error in certain cases, as documented above.


⭐ COMPLEXITY ⭐

O(1)

literally constant time. she's efficient, she's that girl. 🧚


πŸ‘‘ ACL CATEGORIES πŸ‘‘

@admin @dangerous @slow

(dangerous AND slow?? iconic honestly, she contains multitudes πŸ“)


πŸ•°οΈ HISTORY πŸ•°οΈ

  • Available since: 1.0.0

πŸ”₯ SEE ALSO πŸ”₯


okay that's the whole page bestie, go forth and rewrite those append-only files πŸ’–

this has been Valkey Command Manual, version 9.0.0, dated 2025-10-21 β€” mwah, love u, bye πŸŽ€βœ¨

πŸ“¦ where this page comes from