Mercurial > hgrepos > hgweb.cgi > 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 wrap: on
line diff
--- a/s4-blog.sh Wed Apr 22 12:23:33 2020 +0900 +++ b/s4-blog.sh Thu Apr 23 08:14:09 2020 +0900 @@ -270,7 +270,10 @@ [ -s $quizmodefile ] && cond_qz=`cat $quizmodefile` # *** DO NOT USE query(), use "sq $db" instead here *** # because the next block in pipe line uses query() repeatedly. - sq $db<<EOF | + ###### TEST: 2020-04-23 Use intermediate file to shorten duration of db-lock + ###### sq $db<<EOF | + midfile=$tmpd/midfile + query <<EOF > $midfile WITH a_s AS ( SELECT id, max(CASE key WHEN 'ctime' THEN val END) TIME, @@ -336,9 +339,11 @@ a_s s ON a.id=s.id; EOF + cat $midfile | while IFS='|' read id edit notify uid author uname icon aid \ tm reki new hte fa imgids do + mf2=$tmpd/midfile2 cachefile="$td/$id.row.html" stampfile="$td/$id.row.stamp" editlink="${edit:+<a href="$elink+$edit">編集</a> }" @@ -408,7 +413,8 @@ # !!NOTE!! Create row stamp ONLY WHEN imgcache is active else query "SELECT hex(bin) FROM article_m WHERE rowid=$mrid;" \ - | unhexize \ + > $mf2 # Stop query here 2020-04-23 + cat $mf2| unhexize \ | convert -define ${fmt}:size=100x100 -resize 100x100'>' \ - ${fmt}:- \ | tee "$outfile" \ @@ -694,6 +700,7 @@ isgrpowner "$user" "$owner" && isgrpadmin=true || isgrpadmin=false i=0 + midfile=$tmpd/midfile bd=$tmpd/archive.$$ mkdir $bd case "$mode" in @@ -748,12 +755,12 @@ AND s.key='text'; EOF fi - query <<-EOF | + query <<-EOF > $midfile # Using tempfile for quick db-unlock SELECT a.rowid, a.id artid, a.author, hex(s.val) FROM article a JOIN article_s s ON a.id=s.id WHERE blogid=(SELECT id FROM blog WHERE rowid=$rid); EOF - while IFS='|' read rowid artid author text; do + cat $midfile | while IFS='|' read rowid artid author text; do isfilereadable $user article_s $rowid || continue dir=`printf $bd/%d/%06d "$rid" "$rowid"` mkdir -p $dir