TSDBBench / YCSB-TS

Clone of YCSB with support for time series data bases
http://tsdbbench.github.io/YCSB-TS/
Apache License 2.0
24 stars 12 forks source link

UniformLongGenerator.nextValue does not guard against divide by zero #11

Open cgmcintyr opened 6 years ago

cgmcintyr commented 6 years ago

Problem

testworload

``` workload=com.yahoo.ycsb.workloads.TimeSeriesWorkload recordcount=1000 operationcount=1000 timestampunits=SECONDS timestampinterval=60 fieldcount=16 fieldlength=8 fieldlengthdistribution=constant tagcount=4 tagcardinality=1,2,4,8 tagkeylength=8 tagvaluelength=8 tagpairdelimiter== deletedelimiter=: randomwritetimestamporder=false randomtimeseriesorder=false valuetype=floats sparsity=0.00 delayedSeries=0.10 delayedIntervals=5 querytimespan=0 queryrandomtimespan=false querytimespandelimiter=, groupbykey=YCSBGB downsamplingkey=YCSBDS readproportion=0.50 updateproportion=0.00 insertproportion=0.50 requestdistribution=zipfian table=usertable dataintegrity=false measurementtype=histogram histogram.buckets=1000 timeseries.granularity=1000 ```


When checked out on fork-folding branch at https://github.com/TSDBBench/YCSB-TS/commit/c02506667383d6ce765b12cf6a136cf87596028a, running the above testworkload on a single node cassandra-backed local kairosdb (https://github.com/kairosdb/kairosdb/releases/tag/v1.2.0) instance results in the following error:

$ ./bin/ycsb run kairosdb -P workloads/testworkloada -p "port=8080" -p "ip=127.0.0.1"
[WARN]  Running against a source checkout. In order to get our runtime dependencies we'll have to invoke Maven. Depending on the state of your system, this may take ~30-45 seconds
[DEBUG]  Running 'mvn -pl com.yahoo.ycsb:kairosdb-binding -am package -DskipTests dependency:build-classpath -DincludeScope=compile -Dmdep.outputFilterFile=true'
java -cp /home/cgmcintyre/devel/uni/dissertation/kairos-db-scylla/YCSB-TS/kairosdb/conf:/home/cgmcintyre/devel/uni/dissertation/kairos-db-scylla/YCSB-TS/kairosdb/target/kairosdb-binding-0.14.0-SNAPSHOT.jar:/home/cgmcintyre/.m2/repository/org/apache/httpcomponents/httpcore/4.3.2/httpcore-4.3.2.jar:/home/cgmcintyre/.m2/repository/org/apache/htrace/htrace-core4/4.1.0-incubating/htrace-core4-4.1.0-incubating.jar:/home/cgmcintyre/.m2/repository/com/google/guava/guava/14.0/guava-14.0.jar:/home/cgmcintyre/.m2/repository/org/kairosdb/client/2.2.0/client-2.2.0.jar:/home/cgmcintyre/.m2/repository/org/hdrhistogram/HdrHistogram/2.1.4/HdrHistogram-2.1.4.jar:/home/cgmcintyre/.m2/repository/com/google/code/findbugs/jsr305/2.0.0/jsr305-2.0.0.jar:/home/cgmcintyre/.m2/repository/org/apache/httpcomponents/httpclient/4.3.3/httpclient-4.3.3.jar:/home/cgmcintyre/.m2/repository/org/codehaus/jackson/jackson-core-asl/1.9.4/jackson-core-asl-1.9.4.jar:/home/cgmcintyre/.m2/repository/commons-io/commons-io/2.2/commons-io-2.2.jar:/home/cgmcintyre/devel/uni/dissertation/kairos-db-scylla/YCSB-TS/core/target/core-0.14.0-SNAPSHOT.jar:/home/cgmcintyre/.m2/repository/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar:/home/cgmcintyre/.m2/repository/commons-logging/commons-logging/1.1.3/commons-logging-1.1.3.jar:/home/cgmcintyre/.m2/repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar:/home/cgmcintyre/.m2/repository/org/codehaus/jackson/jackson-mapper-asl/1.9.4/jackson-mapper-asl-1.9.4.jar:/home/cgmcintyre/.m2/repository/com/google/code/gson/gson/2.2.4/gson-2.2.4.jar:/home/cgmcintyre/.m2/repository/commons-codec/commons-codec/1.6/commons-codec-1.6.jar com.yahoo.ycsb.Client -db com.yahoo.ycsb.db.KairosDBClient -P workloads/mytsworkload -p port=8080 -p ip=127.0.0.1 -t
Command line: -db com.yahoo.ycsb.db.KairosDBClient -P workloads/mytsworkload -p port=8080 -p ip=127.0.0.1 -tYCSB Client 0.14.0-SNAPSHOT

Loading workload...
Starting test.
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
DBWrapper: report latency for each error is false and specific error codes to track for latency are: []
java.lang.ArithmeticException: / by zero
    at com.yahoo.ycsb.generator.UniformLongGenerator.nextValue(UniformLongGenerator.java:44)
    at com.yahoo.ycsb.generator.UniformLongGenerator.nextValue(UniformLongGenerator.java:25)
    at com.yahoo.ycsb.workloads.TimeSeriesWorkload.doTransactionRead(TimeSeriesWorkload.java:735)
    at com.yahoo.ycsb.workloads.TimeSeriesWorkload.doTransaction(TimeSeriesWorkload.java:711)
    at com.yahoo.ycsb.ClientThread.run(Client.java:454)
    at java.lang.Thread.run(Thread.java:748)
java.lang.ArithmeticException: / by zero
    at com.yahoo.ycsb.generator.UniformLongGenerator.nextValue(UniformLongGenerator.java:44)
    at com.yahoo.ycsb.generator.UniformLongGenerator.nextValue(UniformLongGenerator.java:25)
    at com.yahoo.ycsb.workloads.TimeSeriesWorkload.doTransactionRead(TimeSeriesWorkload.java:735)
    at com.yahoo.ycsb.workloads.TimeSeriesWorkload.doTransaction(TimeSeriesWorkload.java:711)
    at com.yahoo.ycsb.ClientThread.run(Client.java:454)
    at java.lang.Thread.run(Thread.java:748)

Cause

If the following holds for workload values:

(nb: right sight of operator is how TimeSeriesWorkload.totalcardinality is calculated)

Then TimeSeriesWorkload.maxOffsets is set to 1 by:

https://github.com/TSDBBench/YCSB-TS/blob/035310c50dab7432771b5d0bc33ef4f2aaa67fde/core/src/main/java/com/yahoo/ycsb/workloads/TimeSeriesWorkload.java#L1026

This results in TimeSeriesWorkload.queryOffsetGenerator being initialized:

https://github.com/TSDBBench/YCSB-TS/blob/035310c50dab7432771b5d0bc33ef4f2aaa67fde/core/src/main/java/com/yahoo/ycsb/workloads/TimeSeriesWorkload.java#L1159

Which causes TimeSeriesWorkload.queryOffsetGenerator.interval to equal 0:

https://github.com/TSDBBench/YCSB-TS/blob/59bc986a088a508a07144b425a9389ff6fc85843/core/src/main/java/com/yahoo/ycsb/generator/UniformLongGenerator.java#L36-L40

Causing a divide by zero error when TimeSeriesWorkload.queryOffsetGenerator.nextValue is called:

https://github.com/TSDBBench/YCSB-TS/blob/59bc986a088a508a07144b425a9389ff6fc85843/core/src/main/java/com/yahoo/ycsb/generator/UniformLongGenerator.java#L44

Proposed solution

Set interval to a sensible default value if it is set to zero (and warn user?)