Mercurial > hgrepos > hgweb.cgi > s4
changeset 887:8229c75e9f94
Ensure user_s update
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Tue, 22 Dec 2020 08:24:23 +0900 |
parents | 99187e4ad69b |
children | 7ca1f11ab5e8 |
files | s4-funcs.sh s4-world.sh |
diffstat | 2 files changed, 18 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/s4-funcs.sh Thu Dec 17 07:56:38 2020 +0900 +++ b/s4-funcs.sh Tue Dec 22 08:24:23 2020 +0900 @@ -1411,6 +1411,15 @@ mypwhash() { mycrypt "`cat`" `genrandom 5` } +flag_profupdate() { + # XXX: Sorry to use undeclared column in user.def + # This is useful to mitigate account sync load + query <<-EOF + REPLACE INTO user_s(name, key, type, val) + VALUES('$user', 'profupdate', 'string', datetime('now', 'localtime')); + EOF + touch $userupdateflag +} wasureta() { user=$1 if ! checkdomain $user; then @@ -4247,15 +4256,7 @@ RELEASE SAVEPOINT pa2table_insert; EOF rc=$? - if [ $rc -eq 0 -a x"$tbl" = x"user" ]; then - # XXX: Sorry to use undeclared column in user.def - # This is useful to mitigate account sync load - query <<-EOF - REPLACE INTO user_s(name, key, type, val) - VALUES('$user', 'profupdate', 'string', datetime('now', 'localtime')); - EOF - touch $userupdateflag - fi + [ $rc -eq 0 -a x"$tbl" = x"user" ] && flag_profupdate ## err "Table:$tbl update done " return $rc )
--- a/s4-world.sh Thu Dec 17 07:56:38 2020 +0900 +++ b/s4-world.sh Tue Dec 22 08:24:23 2020 +0900 @@ -78,6 +78,7 @@ fi fi err "`gdate +%S.%3N` Starting account synchronization" + SYNC_M=1 prevsync=`tail -1 $syncflag|colrm 20` # 2020-06-21 12:30:00 = 19cols syncall=${db%.*}.syncall @@ -96,6 +97,7 @@ else err synccond canceled for user_m SYNCCOND="WHERE NULL" + SYNC_M= fi err "Touch $syncall (owner=`id -un`) to update all user_m." ;; @@ -114,23 +116,24 @@ DELETE FROM main.user_s WHERE rowid NOT IN (SELECT rowid FROM m.user_s); REPLACE INTO main.user_s(rowid, name, key, type, val, bin) SELECT rowid,* FROM m.user_s; +${SYNC_M:+ DELETE FROM main.user_m WHERE rowid NOT IN (SELECT rowid FROM m.user_m); REPLACE INTO main.user_m(rowid, name, key, type, val, bin) SELECT rowid,* FROM m.user_m $SYNCCOND EXCEPT SELECT rowid,* FROM main.user_m $SYNCCOND - ; + ;} /* SYNC_M closed here */ END; /* Compare user tables */ WITH master AS ( SELECT p.rowid,* FROM m.user p - NATURAL LEFT JOIN m.user_s - NATURAL LEFT JOIN m.user_m + NATURAL LEFT JOIN m.user_s + ${SYNC_M:+ NATURAL LEFT JOIN m.user_m} ), thisworld AS ( SELECT p.rowid,* FROM user p - NATURAL LEFT JOIN user_s - NATURAL LEFT JOIN user_m + NATURAL LEFT JOIN user_s + ${SYNC_M:+ NATURAL LEFT JOIN user_m} ), m_a AS ( SELECT * FROM master EXCEPT SELECT * FROM thisworld ), a_m AS (