# HG changeset patch # User HIROSE Yuuji # Date 1608593063 -32400 # Node ID 8229c75e9f946036189145efb497f4e10f5b5f62 # Parent 99187e4ad69b364c9cee5c3d20c120cb3cb7d8a0 Ensure user_s update diff -r 99187e4ad69b -r 8229c75e9f94 s4-funcs.sh --- 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 ) diff -r 99187e4ad69b -r 8229c75e9f94 s4-world.sh --- 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 (