s4

changeset 629:b1ddb2559d77

TEST: Use intermediate file instead of query-pipe to shorten db-lock
author HIROSE Yuuji <yuuji@gentei.org>
date Thu, 23 Apr 2020 08:14:09 +0900
parents 5c9b7add02e9
children 8874225971ff
files s4-blog.sh
diffstat 1 files changed, 11 insertions(+), 4 deletions(-) [+]
line diff
     1.1 --- a/s4-blog.sh	Wed Apr 22 12:23:33 2020 +0900
     1.2 +++ b/s4-blog.sh	Thu Apr 23 08:14:09 2020 +0900
     1.3 @@ -270,7 +270,10 @@
     1.4    [ -s $quizmodefile ] && cond_qz=`cat $quizmodefile`
     1.5    # *** DO NOT USE query(), use "sq $db" instead here ***
     1.6    # because the next block in pipe line uses query() repeatedly.
     1.7 -  sq $db<<EOF |
     1.8 +  ###### TEST: 2020-04-23 Use intermediate file to shorten duration of db-lock
     1.9 +  ###### sq $db<<EOF |
    1.10 +  midfile=$tmpd/midfile
    1.11 +  query <<EOF > $midfile
    1.12  WITH a_s AS (
    1.13    SELECT id,
    1.14           max(CASE key WHEN 'ctime' THEN val END) TIME,
    1.15 @@ -336,9 +339,11 @@
    1.16       a_s s
    1.17    ON a.id=s.id;
    1.18  EOF
    1.19 +  cat $midfile |
    1.20    while IFS='|' read id edit notify uid author uname icon aid \
    1.21  	   tm reki new hte fa imgids
    1.22    do
    1.23 +    mf2=$tmpd/midfile2
    1.24      cachefile="$td/$id.row.html"
    1.25      stampfile="$td/$id.row.stamp"
    1.26      editlink="${edit:+<a href="$elink+$edit">編集</a> }"
    1.27 @@ -408,7 +413,8 @@
    1.28  		# !!NOTE!! Create row stamp ONLY WHEN imgcache is active
    1.29  	      else
    1.30  		query "SELECT hex(bin) FROM article_m WHERE rowid=$mrid;" \
    1.31 -		    | unhexize \
    1.32 +		      > $mf2  # Stop query here 2020-04-23
    1.33 +		cat $mf2| unhexize \
    1.34  		    | convert -define ${fmt}:size=100x100 -resize 100x100'>' \
    1.35  			      - ${fmt}:- \
    1.36  		    | tee "$outfile" \
    1.37 @@ -694,6 +700,7 @@
    1.38    isgrpowner "$user" "$owner" && isgrpadmin=true || isgrpadmin=false
    1.39    
    1.40    i=0
    1.41 +  midfile=$tmpd/midfile
    1.42    bd=$tmpd/archive.$$
    1.43    mkdir $bd
    1.44    case "$mode" in
    1.45 @@ -748,12 +755,12 @@
    1.46  	       AND s.key='text';
    1.47  	EOF
    1.48    fi
    1.49 -  query <<-EOF |
    1.50 +  query <<-EOF > $midfile		# Using tempfile for quick db-unlock
    1.51  	SELECT a.rowid, a.id artid, a.author, hex(s.val)
    1.52  	FROM article a JOIN article_s s ON a.id=s.id
    1.53  	WHERE blogid=(SELECT id FROM blog WHERE rowid=$rid);
    1.54  	EOF
    1.55 -  while IFS='|' read rowid artid author text; do
    1.56 +  cat $midfile | while IFS='|' read rowid artid author text; do
    1.57      isfilereadable $user article_s $rowid || continue
    1.58      dir=`printf $bd/%d/%06d "$rid" "$rowid"`
    1.59      mkdir -p $dir