ERROR collector unable to delete piece

Do you convert the filenames to lower case? I’m not fluent in Powershell, so I can’t tell. The case in filenames matters in *nix.

Here’s my bash script

#!/bin/bash

if [ "$1" == "" ];then
  echo "usage $0 <storagenode_base_dir> [test]"
  exit 1
fi

tempfile="/tmp/$$.log"

grep $(date "+%Y-%m-%dT%H" -d '2 hour ago') $1/node.log|grep -E "ERROR\s+collector\s+unable to delete piece"|cut -d'"' -f8,12 > $tempfile

if [ $(cat $tempfile|wc -l) -gt 0 ];then
  while IFS= read -r line;do
    satellite=$(echo $line|cut -d '"' -f1)
    #converting piece_id from log to lower case and inserts a "/" after the 2nd character
    piece_id=$(echo $line|cut -d '"' -f2|tr '[:upper:]' '[:lower:]' | sed 's:^\(.\{2\}\):\1/:')

    case $satellite in
      121RTSDpyNZVcEU84Ticf2L1ntiuUimbWgfATz21tuvgk3vzoA6)
        blob=qstuylguhrn2ozjv4h2c6xpxykd622gtgurhql2k7k75wqaaaaaa
        ;;

      12EayRS2V1kEsWESU9QMRseFhdxYxKicsiFmxrsLZHeLUtdps3S)
        blob=ukfu6bhbboxilvt7jrwlqk7y2tapb5d2r2tsmj2sjxvw5qaaaaaa
        ;;

      12L9ZFwhzVpuEKMUNUqkaTLGzwY9G24tbiigLiXpmZWKwmcNDDs)
        blob=v4weeab67sbgvnbwd5z7tweqsqqun7qox2agpbxy44mqqaaaaaaa
        ;;

      1wFTAgs9DP5RSnCqKV1eLf6N9wtk4EAtmN5DpSxcs8EjT69tGE)
        blob=pmw6tvzmf2jv6giyybmmvl4o2ahqlaldsaeha4yx74n5aaaaaaaa
        ;;

      12rfG3sh9NCWiX3ivPjq2HtdLmbqCrvHVEzJubnzFzosMuawymB)
       blob=6r2fgwqz3manwt4aogq343bfkh2n5vvg4ohqqgggrrunaaaaaaaa
       ;;

      12tRQrMTWUWwzwGh18i7Fqs67kmdhH9t6aToeiwbo5mfS2rUmo)
        blob=arej6usf33ki2kukzd5v6xgry2tdr56g45pp3aao6llsaaaaaaaa
        ;;
      *)
        echo "Satellite $2 doesn't exist"
        break 1
        ;;

    esac

    if [ -d $1/storage/blobs ];then
      if [ "$2" == "test" ];then
        echo "Satellite $satellite      piece ID $piece_id"
      else
        touch $1/storage/blobs/${blob}/${piece_id}.sj1
        ls -la $1/storage/blobs/${blob}/${piece_id}.sj1
      fi
    fi
  done < $tempfile
fi

rm $tempfile

Use at your own risk. The script assumes the log is in the root folder of the node and is called "node.log. Adjust accordingly. Also adjust “2 hours ago” in the line

grep $(date "+%Y-%m-%dT%H" -d '2 hour ago') $1/node.log|grep -E "ERROR\s+collector\s+unable to delete piece"|cut -d'"' -f8,12 > $tempfile

to your offset between your local time and the time inside the container. My offset is 1h, so I use “2 hours ago” to grep the previous hour of the log.

If you use “test” as second parameter the script just prints out the pieceid’s together with the corresponding satellite.

2 Likes