FAQ - Are AQL commands executed synchronously?

FAQ - Are AQL commands executed synchronously?


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


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.




JUL 2020

© 2015 Copyright Aerospike, Inc. | All rights reserved. Creators of the Aerospike Database.