ScanAll and aql select timeout!

Hey there,

I’m getting timeouts (no matter what TIMEOUT is set to) when executing a scan.

Using Go:

Just gets to: “Printing…”

Using AQL:

INSERT INTO test.demo (PK, foo, bar) VALUES (‘key1’, 123, ‘abc’)
| n_objects | disable-eviction | set-enable-xdr | n-bytes-memory | ns_name | set_name | set-delete |
| 1 | “false” | “use-default” | 34 | “test” | “demo” | “false” |

SELECT * FROM test.demo
Error: (9) Timeout: timeout=1000 iterations=1 failedNodes=0 failedConns=0

SELECT * FROM test.demo WHERE PK = 'key1’
Specifying they key works fine!

What’s the reason behind scanning one record working but scanning all not working?

Your gist doesn’t show you setting any timeout explicitly, so it will be using the default of 1000ms, and similarly your AQL query fails when you use the default timeout value. In both cases, set a higher timeout, because it seems to require that for your data.

Getting a single record is much faster because Aerospike is like a distributed hash table and a single key lookup is O(1). A scan, however, has to go over the 4096 logical partitions of the namespace looking at each record within those for whether it matches your specified set.

1 Like

Hey @rbotzer thanks for the quick reply!
As I mentioned in the beginning of my original post: “I’m getting timeouts (no matter what TIMEOUT is set to) when executing a scan”

I’m sorry for not explicitly adding it to the Gist (that was my bad), just updated it. The same goes for the AQL part.

The output for the Golang app:

go run main.go

Adding the time out here, worked. But didn’t get/print any data at all.

And for the AQL part:

aql> SET TIMEOUT 60000
aql> SELECT * FROM test.demo
Error: (9) Timeout: timeout=60000 iterations=1 failedNodes=0 failedConns=0

Now, a key part here is that test.demo has only 1 record as you can see under n_objects of my original post.

So, I understand your point about the lookup complexity for a single key vs a scan, but 60 seconds should be enough? :slight_smile:

Any other ideas why this should be happening?

Well, something is going on, because that’s plenty of time. In general, small set scans (such as this) take a lot of time relative to the size of the data, because of the overhead of scanning the 4096 partitions. It’s something that amortizes well over a large set of data. There will be an improvement of this in future releases.

Still, this is wrong. How many nodes in your cluster, and what’s the version of the server and client you’re using?

Hey @rbotzer I’m pasting the full asinfo output just in case:

asinfo -h <node_ip> -p 3000
1 :  node
2 :  statistics
3 :  features
4 :  cluster-generation
5 :  partition-generation
6 :  edition
     Aerospike Community Edition
7 :  version
     Aerospike Community Edition build 3.6.3
8 :  build
9 :  services
10 :  services-alumni


  • cluster_size=2
  • Aerospike Community Edition build 3.6.3
  • Aerospike Tools 3.8.2 (aql)
  • 1.13.0 Go Client Library (Golang apps)

A quick note - your Go client version is the latest and expects a newer version of the server. If you look at the release notes you’ll see that there are several features that require version > 3.6.

You have a 2 node cluster, so it probably would not be too difficult for you to upgrade to the latest server, currently Let’s see if the problem persists after that.

hey @rbotzer just deployed the new version of the server. Doing an aql SELECT now works!

INSERT INTO test.demo (PK, foo, bar) VALUES (‘key1’, 123, ‘abc’)


| n_objects | disable-eviction | set-enable-xdr | n-bytes-memory | ns_name | set_name | set-delete |
| 1 | “false” | “use-default” | 34 | “test” | “demo” | “false” |

aql> SELECT * FROM test.demo
| foo | bar |
| 123 | “abc” |
1 row in set (0.677 secs)

I still need to do a “real” test from the Go client once all of the data from the old cluster is imported. But this works so far.

Also, something interesting happened when trying to do a ScanAll from test.demo. If I do: championSet, err := client.ScanAll(nil, "test", "demo") it works as expected, printing:

go run main.go
"test:demo::ec 91 19 2d 4b 7f 8c e3 5d 5d 78 d3 4b ca 65 cb aa aa c9 60 "
  "foo": 123,
  "bar": "abc",

But if I create a new scan policy and specify a large timeout value, I get a timeout! e.g:

policy := as.NewScanPolicy()
policy.Timeout = 60000

championSet, err := client.ScanAll(policy, "test", "demo")

produces: 2016/05/13 15:29:49 Error processing results: read tcp> i/o timeout.

I have no idea why this is happening. I will post again, once I import the data from the old cluster and test everything to confirm whether the upgrade solved everything or not.

Thanks a lot for your help!

Hi, you are giving scan command only 60 microseconds to complete, which is way too short.


    policy.Timeout = time.Millisecond

and it will perform properly.

hey @Khosrow_Afroozeh I’m not sure what you mean. By setting policy.Timeout = 60000 I’m effectively giving 60 seconds for the scan to complete. Setting it to 60 second timeout, is working properly after the version upgrade. Before the version upgrade, even 60 seconds weren’t enough. My theory is that maybe something broke? Anyway, it works now :slight_smile:

Thanks for the input though!

60000 in Go time unit (nanoseconds) == 60 microseconds.

To set the timeout to 6 seconds you need 6 * time.Second which equals 6 * 1e9

Hey @Khosrow_Afroozeh you are absolutely right!
I keep forgetting about time.Duration being nanoseconds :frowning2:

Thank you!!!

Just to update everyone and close the thread.
Everything is working as expected after the update.
Go snippet (with the right changes noted by @Khosrow_Afroozeh) and aql queries are working smoothly!

Thanks everyone! :slight_smile:

Hi, If i want to scan small set, is it better to create a secondary index instead of using scan all with timeout?

It depends on the size of the set relative to the size of the namespace it is in. If it’s very small compared to the namespace, you can do one of these:

  • Create a separate namespace for that small set.
  • Create a secondary index over a redundant bin that identifies that set (for example a single character that is indexed, identifying those records as members of the specific set).
© 2015 Copyright Aerospike, Inc. | All rights reserved. Creators of the Aerospike Database.