cassandra-stress tool is throwing error when using a yaml file for user profile

513 Views Asked by At

I am able to run cassandra-stress with default keyspace and tables but With reference of datastax document I was trying to use cassandra-stress tool by using my own profile. Datastax doc - https://docs.datastax.com/en/dse/5.1/dse-admin/datastax_enterprise/tools/toolsCStress.html

I have 2 DC having (2+1) node and cassandra 3.11 setup and I modified yaml file accordingly but I am getting errors.

Command -

cassandra-stress user profile=/var/lib/cassandra/stresstest/cqlstress-example.yaml n=1000000 ops\(insert=3,read1=1\) no-warmup cl=one

Error -

java.io.IOError: while parsing a block mapping
 in 'reader', line 5, column 4:
       CREATE KEYSPACE perftesting WITH ...
       ^
expected <block end>, but found FlowEntry
 in 'reader', line 5, column 87:
     ... lass': 'NetworkTopologyStrategy', 'dc1': 1, 'dc2': 2};
                                         ^

    at org.apache.cassandra.stress.StressProfile.load(StressProfile.java:823)
    at org.apache.cassandra.stress.settings.SettingsCommandUser.<init>(SettingsCommandUser.java:62)
    at org.apache.cassandra.stress.settings.SettingsCommandUser.build(SettingsCommandUser.java:150)
    at org.apache.cassandra.stress.settings.SettingsCommand.get(SettingsCommand.java:217)
    at org.apache.cassandra.stress.settings.StressSettings.get(StressSettings.java:264)
    at org.apache.cassandra.stress.settings.StressSettings.parse(StressSettings.java:241)
    at org.apache.cassandra.stress.Stress.run(Stress.java:80)
    at org.apache.cassandra.stress.Stress.main(Stress.java:62)
Caused by: while parsing a block mapping
 in 'reader', line 5, column 4:
       CREATE KEYSPACE perftesting WITH ...
       ^
expected <block end>, but found FlowEntry
 in 'reader', line 5, column 87:
     ... lass': 'NetworkTopologyStrategy', 'dc1': 1, 'dc2': 2};
                                         ^
    at org.yaml.snakeyaml.parser.ParserImpl$ParseBlockMappingKey.produce(ParserImpl.java:570)
    at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:158)
    at org.yaml.snakeyaml.parser.ParserImpl.checkEvent(ParserImpl.java:143)
    at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:230)
    at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:159)
    at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:237)
    at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:159)
    at org.yaml.snakeyaml.composer.Composer.composeDocument(Composer.java:122)
    at org.yaml.snakeyaml.composer.Composer.getSingleNode(Composer.java:105)
    at org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseConstructor.java:120)
    at org.yaml.snakeyaml.Yaml.loadFromReader(Yaml.java:481)
    at org.yaml.snakeyaml.Yaml.loadAs(Yaml.java:475)
    at org.apache.cassandra.stress.StressProfile.load(StressProfile.java:814)
    ... 7 more

Content of cqlstress-example.yaml

keyspace: perftesting

keyspace_definition: 

  CREATE KEYSPACE perftesting WITH replication = { 'class': 'NetworkTopologyStrategy', 'dc1': 1, 'dc2': 2};
  
table: users

table_definition:

  CREATE TABLE users (
    username text,
    first_name text,
    last_name text,
    password text,
    email text,
    last_access timeuuid,
    PRIMARY KEY(username)
  );

extra_definitions:
  - CREATE MATERIALIZED VIEW perftesting.users_by_first_name AS SELECT * FROM perftesting.users WHERE first_name IS NOT NULL and username IS NOT NULL PRIMARY KEY (first_name, username);
  - CREATE MATERIALIZED VIEW perftesting.users_by_first_name2 AS SELECT * FROM perftesting.users WHERE first_name IS NOT NULL and username IS NOT NULL PRIMARY KEY (first_name, username);
  - CREATE MATERIALIZED VIEW perftesting.users_by_first_name3 AS SELECT * FROM perftesting.users WHERE first_name IS NOT NULL and username IS NOT NULL PRIMARY KEY (first_name, username);

columnspec:
  - name: username
    size: uniform(10..30)
  - name: first_name
    size: fixed(16)
  - name: last_name
    size: uniform(1..32)
  - name: password
    size: fixed(80) # sha-512
  - name: email
    size: uniform(16..50)
  - name: startdate
    cluster: uniform(20...40)
  - name: description
    size: gaussian(100...500)
  
insert:
  partitions: fixed(10)
  batchtype: UNLOGGED

queries:
  read1:
    cql: select * from users where username = ? and startdate = ?
    fields: samerow     # samerow or multirow (select arguments from the same row, or randomly from all rows in the partition)  
2

There are 2 best solutions below

0
On

Like @Aaron said, it's better to define the schema beforehand.

On another note, be careful about multiline CQL statements in the yaml file. I found that changing multiline to single line statements solved most of my problems.

Having an IDE with yaml syntax highlighting might help here to see if your syntax is what you want.

0
On

The yaml parser in cassandra-stress is pretty strict. I've always had more success with defining schema ahead of time, and just using stress to insert/query data.

My suggestion would be to remove the CREATE statements from your stress.yaml, run them beforehand via cqlsh, and try again.