Skip to content

Commit

Permalink
Allow to skip 'truncate table' operation using 'sequential' workload
Browse files Browse the repository at this point in the history
If it is needed to skip truncation of a DB table, then just use
following new parameter:

  -skip-truncate-table

With this change it will be possible to use multiple scylla-bench
concurrent commands which won't truncate each other's data.

Closes: #30
Closes: #130
  • Loading branch information
vponomaryov committed Oct 17, 2024
1 parent 6eca1c9 commit 4070454
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ var (
password string

mode string
workload string
latencyType string
maxErrorsAtRow int
maxErrors int
Expand Down Expand Up @@ -105,6 +106,7 @@ var (
hdrLatencyUnits string
hdrLatencySigFig int
validateData bool
skipTruncateTable bool
)

func Query(session *gocql.Session, request string) {
Expand All @@ -128,10 +130,16 @@ func PrepareDatabase(session *gocql.Session, replicationFactor int) {

}
if validateData {
if workload == "sequential" && skipTruncateTable {
log.Printf("Skip truncating of the '" + tableName + "' table")
return
}
switch mode {
case "write":
log.Printf("Truncating the '" + tableName + "' table")
Query(session, "TRUNCATE TABLE "+keyspaceName+"."+tableName)
case "counter_update":
log.Printf("Truncating the '" + counterTableName + "' table")
Query(session, "TRUNCATE TABLE "+keyspaceName+"."+counterTableName)
}
}
Expand Down Expand Up @@ -246,7 +254,6 @@ func getRetryPolicy() *gocql.ExponentialBackoffRetryPolicy {

func main() {
var (
workload string
consistencyLevel string
replicationFactor int

Expand Down Expand Up @@ -315,6 +322,9 @@ func main() {
flag.StringVar(&hdrLatencyUnits, "hdr-latency-units", "ns", "ns (nano seconds), us (microseconds), ms (milliseconds)")
flag.IntVar(&hdrLatencySigFig, "hdr-latency-sig", 3, "significant figures of the hdr histogram, number from 1 to 5 (default: 3)")

flag.BoolVar(
&skipTruncateTable, "skip-truncate-table", false,
"Skip truncation of a table before running 'write' or 'counter_update' stress commands if workload is 'sequential'")
flag.BoolVar(&validateData, "validate-data", false, "write meaningful data and validate while reading")

var startTimestamp int64
Expand Down

0 comments on commit 4070454

Please sign in to comment.