FAQ - Are AQL commands executed synchronously?

The Aerospike Knowledge Base has moved to https://support.aerospike.com. Content on https://discuss.aerospike.com is being migrated to either https://support.aerospike.com or https://docs.aerospike.com. Maintenance on articles stored in this repository ceased on December 31st 2022 and this article may be stale. If you have any questions, please do not hesitate to raise a case via https://support.aerospike.com.

FAQ - Are AQL commands executed synchronously?

Overview

If I have a text file containing 1000 delete statements, would AQL send the delete requests synchronously (i.e. only send the statement after received the response of the previous statement)?

aql -h seed-node -z 1 -f deletestatementfile.txt

Answer

The quick answer is yes. AQL will execute requests synchronously. To illustrate this, you can use the strace command.

Assume a simple script testdel.aql as follows:

insert INTO test.demo (PK,a) VALUES ('key1', 1000)
DELETE FROM test.demo WHERE PK = 'key1'
DELETE FROM test.demo WHERE PK = 'key1'

You can run strace as such:

strace -ttt aql -Uadmin -Padmin -z 1 -f testdel.aql &> /tmp/test.out

And grepping the result output:

egrep 'sendto\(4|VIOL' /tmp/test.out

1587747620.296625 sendto(4, "\2\2\0\0\0\0\0\\\0\0\0\2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\6\0adm"..., 100, MSG_NOSIGNAL, NULL, 0) = 100
1587747620.296920 sendto(4, "\2\1\0\0\0\0\0\vpartitions\n", 19, MSG_NOSIGNAL, NULL, 0) = 19
1587747620.336963 sendto(4, "\2\3\0\0\0\0\0R\26\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\3\350\0\3\0\1\0\0"..., 90, MSG_NOSIGNAL, NULL, 0) = 90
1587747620.337370 write(2, "Error: (81) AEROSPIKE_ROLE_VIOLA"..., 38Error: (81) AEROSPIKE_ROLE_VIOLATION
1587747620.337614 sendto(4, "\2\3\0\0\0\0\0A\26\0\3\0\0\0\0\0\0\0\0\0\0\0\0\0\3\350\0\3\0\0\0\0"..., 73, MSG_NOSIGNAL, NULL, 0) = 73
1587747620.337975 write(2, "Error: (81) AEROSPIKE_ROLE_VIOLA"..., 38Error: (81) AEROSPIKE_ROLE_VIOLATION
1587747620.338210 sendto(4, "\2\3\0\0\0\0\0A\26\0\3\0\0\0\0\0\0\0\0\0\0\0\0\0\3\350\0\3\0\0\0\0"..., 73, MSG_NOSIGNAL, NULL, 0) = 73
1587747620.338571 write(2, "Error: (81) AEROSPIKE_ROLE_VIOLA"..., 38Error: (81) AEROSPIKE_ROLE_VIOLATION

As observed from the output, commands were sent one at a time and waiting for the reply (in this particular example, it was getting a role violation) before sending the next request. But the purpose was simply to illustrate the fact that AQL indeed does send one command at a time.

Keywords

AQL SYNCHRONOUS STRACE

Timestamp

JUL 2020