#! /bin/bash

n=3    # Number of file sets to delete
s=1000 # Size of Data files to delete
c=0    # Counter to avoid infinite loop

files=`find /var/lib/scylla/data/keyspace1/*/ -maxdepth 1 -type f -size "+"$s"M" -exec ls -latr {} + | head -$n | awk '{print$9}' | cut -f 1,2,3,4,5 -d '-'`
echo "Chosen files are: $files"
while [ "$files" = "" ] && [ $c -lt 10 ]
do
        echo "Empty!, looking for files half the size"
        s=$((s / 2))
        echo "size to find is:" $s
        files=`find /var/lib/scylla/data/keyspace1/*/ -maxdepth 1 -type f -size "+"$s"M" -exec ls -latr {} + | head -$n | awk '{print$9}' | cut -f 1,2,3,4,5 -d '-'`
	echo "Chosen files are: $files"
        c=$((c+1))
        if [ $c -eq 10 ]
        then
                echo "Max retries reached - exiting"
        fi
done

for f in $files
do
    # Changed because of name format seems was changed.
    # And now there is no db files named as ".db-*"
    f="$f*"
	echo "About to delete $f"
        rm -f $f
        echo "Deletion exit code is" $?
done

#! /bin/bash

n=3    # Number of file sets to delete
s=1000 # Size of Data files to delete
c=0    # Counter to avoid infinite loop

files=`find /var/lib/scylla/data/keyspace1/*/ -maxdepth 1 -type f -size "+"$s"M" -exec ls -latr {} + | head -$n | awk '{print$9}' | cut -f 1,2,3,4,5 -d '-'`
echo "Chosen files are: $files"
while [ "$files" = "" ] && [ $c -lt 10 ]
do
        echo "Empty!, looking for files half the size"
        s=$((s / 2))
        echo "size to find is:" $s
        files=`find /var/lib/scylla/data/keyspace1/*/ -maxdepth 1 -type f -size "+"$s"M" -exec ls -latr {} + | head -$n | awk '{print$9}' | cut -f 1,2,3,4,5 -d '-'`
	echo "Chosen files are: $files"
        c=$((c+1))
        if [ $c -eq 10 ]
        then
                echo "Max retries reached - exiting"
        fi
done

for f in $files
do
        f="$f-*"
	echo "About to delete $f"
        rm -f $f
        echo "Deletion exit code is" $?
done

Revert "Remove files for repair test: change file name template for deletetion"
Revert "Remove files for repair test: change file name template for deletetion"

We need to clean all files not only DB, but TOC, etc.

This reverts commit 33fcf0eeed0cdf15f581e12a8661a0f40fb05c73.
