WAITAOF
Since 1.1.0ServerChanged in 1.2.1
Syntax
WAITAOF numlocal numreplicas timeoutHistory
- 1.2.1: acl categories: added connection; removed generic, keyspace, read
Waits for pending writes to be fsynced to the local append-only file, or until timeout milliseconds pass.
In 1.2, numreplicas is accepted but ignored: KiviDB does not track replicas' AOF fsync acknowledgements, and the second number in the reply is always 0. The timeout applies only to the local fsync; the command does not wait for replicas. WAIT can wait for replication acknowledgements, but those do not confirm that a replica has fsynced its AOF.
Inside MULTI it is queued, and answers at once when EXEC runs it, since 1.2.1. It is in the @connection ACL category since 1.2.1, no longer in @read, @keyspace and @generic: a user given +@read but not +@connection needs +waitaof.
Reply
- A two-element array: the local fsync status,
0or1, followed by0for replicas. With the AOF on, the first is1once the writes are fsynced, whatevernumlocalasked for, as in Redis. ERR WAITAOF cannot be used when numlocal is set but appendonly is disabled., with the AOF off andnumlocalabove 0.WAITAOF 0 ...then replies[0, 0].
Before 1.2, with the AOF off, it replied [1, 0], as if the writes had been fsynced, and with the AOF on, the first number was 0 for numlocal 0.
Examples
> WAITAOF 1 0 0
(error) ERR WAITAOF cannot be used when numlocal is set but appendonly is disabled.
> CONFIG SET appendonly yes
OK
> SET a 1
OK
> WAITAOF 1 0 0
1) (integer) 1
2) (integer) 0
> WAITAOF 1 1 10000
1) (integer) 1
2) (integer) 0
The last call returns once the local fsync completes, even without a replica; it does not wait ten seconds for one.