How to detect illegal characters in Set names

FAQ How to detect illegal characters in Set names

Context

Set names cannot contain the ‘:’ or ‘;’ characters. Set names should also not contain any control characters(ie: CR, CL etc from cut and paste). If a set is created with such characters, these sets will not consistently be visible to Aerospike tools and may give unpredictable results in the statistics.

Method

We can use a couple of tools like asinfo and od -c command line tool to check for hidden characters or illegal characters in a Set name.

Getting illegal characters in Set names from asinfo

The following command will list all sets and include their illegal characters.

asinfo -v sets -l|sed -e 's/:objects.*//g'

Getting hidden characters in sets names od command line

asinfo -v sets -l|sed -e 's/:objects.*//g'|od -c

Example

  • Insert 3 illegal sets with a colon and semi-colon and one additional set with a [CTRL]-[V]-[D]
aql> INSERT INTO test.'demo:set1.colon' (PK, foo, bar) VALUES ('key1', 123, 'abc')
OK, 1 record affected.

aql> INSERT INTO test.'demo;set2.semi-colon' (PK, foo, bar) VALUES ('key2', 123, 'abc')
OK, 1 record affected.

aql> INSERT INTO test.'set3^D' (PK, foo, bar) VALUES ('key3', 123, 'abc')
OK, 1 record affected.
  • aql show sets shows a truncated name for some of the sets:
aql> show sets
+------------------+--------+----------------+---------+-------------------+---------+-------------------+--------------+------------+------------+-----------------+
| disable-eviction | ns     | set-enable-xdr | objects | stop-writes-count | set     | memory_data_bytes | truncate_lut | tombstones | set1.colon | set2.semi-colon |
+------------------+--------+----------------+---------+-------------------+---------+-------------------+--------------+------------+------------+-----------------+
| "false"          | "test" | "use-default"  | "0"     | "0"               | "demo"  | "0"               | "0"          | "0"        |            |                 |
| "false"          | "test" | "use-default"  | "1"     | "0"               | "demo"  | "34"              | "0"          | "0"        |            |                 |
|                  | "test" |                |         |                   | "demo"  |                   |              |            |            |                 |
| "false"          |        | "use-default"  | "1"     | "0"               |         | "34"              | "0"          | "0"        |            |                 |
| "false"          | "test" | "use-default"  | "1"     | "0"               | "set3" | "34"              | "0"          | "0"        |            |                 |
+------------------+--------+----------------+---------+-------------------+---------+-------------------+--------------+------------+------------+-----------------+
[127.0.0.1:3000] 5 rows in set (0.002 secs)

OK

The asinfo command should show the true set names: (The set with the semi-colon “demo;set2.semi-colon” actually shows as two lines.)

$ asadm --no-config-file -e "asinfo -v sets -l"|sed -e 's/:objects.*//g'
Seed:        [('127.0.0.1', 3000, None)]
Config_file: None
192.168.106.37:3000 (192.168.106.37) returned:
ns=test:set=demo
ns=test:set=demo:set1.colon
ns=test:set=demo
set2.semi-colon
ns=test:set=set3

You can notice that set3 still shows up at first glance as a normal set, though it was created with a control character CTRL-V-D

The use of the od -c command line shows the hidden character after “set3” in this example as an octal value “004” .

$ asinfo -v sets -l|sed -e 's/:objects.*//g'|od -c
0000000   n   s   =   t   e   s   t   :   s   e   t   =   d   e   m   o
0000020  \n   n   s   =   t   e   s   t   :   s   e   t   =   d   e   m
0000040   o   :   s   e   t   1   .   c   o   l   o   n  \n   n   s   =
0000060   t   e   s   t   :   s   e   t   =   d   e   m   o  \n   s   e
0000100   t   2   .   s   e   m   i   -   c   o   l   o   n  \n   n   s
0000120   =   t   e   s   t   :   s   e   t   =   s   e   t   3 004  \n
0000140

Keywords

setnames illegal characters control hidden

Timestamp

October 2019

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