Bash

Dependencies

  • mysql client program

  • Bourne-Again Shell (bash)

Code

#!/bin/bash
MHOST="127.0.0.1"
MPORT="3306"
MUSER="root"
MDB=""
NUM_WORKERS=128
BATCH_SIZE=256
memsql_exec()
{
mysql -h $MHOST -P $MPORT -u $MUSER $MDB -e "$1"
}
memsql_exec_multi()
{
mysql -h $MHOST -P $MPORT -u $MUSER $MDB -e \
"$(for ((b = 0; b < $BATCH_SIZE; b++)); do
echo "$1;"
done)"
}
echo "Creating database test"
memsql_exec "CREATE DATABASE IF NOT EXISTS test"
MDB="test"
echo "Creating table tbl"
memsql_exec "CREATE TABLE IF NOT EXISTS tbl (id INT AUTO_INCREMENT PRIMARY KEY)"
echo "Launching $NUM_WORKERS workers"
sleep 1
declare -a WORKERS
for ((worker = 0; worker < $NUM_WORKERS; worker++)); do
(while [ 1 ]; do
echo "Worker $worker inserting"
memsql_exec_multi "INSERT INTO tbl VALUES (NULL)"
done) &
WORKERS[$worker]=$!
done
sleep 10
for ((worker = 0; worker < $NUM_WORKERS; worker++)); do
echo "Killing worker $worker"
kill ${WORKERS[$worker]}
wait ${WORKERS[$worker]} 2>/dev/null
done
echo "Cleaning up"
sleep 1
memsql_exec "DROP DATABASE test"

Last modified: August 21, 2023

Was this article helpful?

Verification instructions

Note: You must install cosign to verify the authenticity of the SingleStore file.

Use the following steps to verify the authenticity of singlestoredb-server, singlestoredb-toolbox, singlestoredb-studio, and singlestore-client SingleStore files that have been downloaded.

You may perform the following steps on any computer that can run cosign, such as the main deployment host of the cluster.

  1. (Optional) Run the following command to view the associated signature files.

    curl undefined
  2. Download the signature file from the SingleStore release server.

    • Option 1: Click the Download Signature button next to the SingleStore file.

    • Option 2: Copy and paste the following URL into the address bar of your browser and save the signature file.

    • Option 3: Run the following command to download the signature file.

      curl -O undefined
  3. After the signature file has been downloaded, run the following command to verify the authenticity of the SingleStore file.

    echo -n undefined |
    cosign verify-blob --certificate-oidc-issuer https://oidc.eks.us-east-1.amazonaws.com/id/CCDCDBA1379A5596AB5B2E46DCA385BC \
    --certificate-identity https://kubernetes.io/namespaces/freya-production/serviceaccounts/job-worker \
    --bundle undefined \
    --new-bundle-format -
    Verified OK