about summary refs log tree commit diff
path: root/scripts
diff options
context:
space:
mode:
authorAlexander_Kabui <alexanderkabui@proton.me>2026-10-14 07:28:47 +0300
committerAlexander_Kabui <alexanderkabui@proton.me>2026-10-14 07:28:47 +0300
commit82f1e85a4c011b18aca476dca66a335981b05e4f (patch)
treea7be75fbb666e4fb28bbf3608bb106c55c568989 /scripts
parentd607e8faa7692f28f7e6cf3d0517a69a44557a27 (diff)
downloadgenenetwork4-82f1e85a4c011b18aca476dca66a335981b05e4f.tar.gz
indexer delta: fall back to FULL on a case-only dataset rename
* src/indexer/delta.rs (scan): enumerate dataset labels under COLLATE
  utf8mb4_bin so a case-only rename's old and new labels both enter scope;
  route to FULL when a case-variant label pair is in the affected scope.
* src/indexer/run.rs (run_delta): seed the duplicate-check map with manifest
  labels not in scope; route to FULL when a manifest carries an unknown
  versioning flavour.
* scripts/gn-indexer-lag.sh: honour the table-prefix seam only with the
  explicit test opt-in; treat a literal NULL MAX as no change; guard an
  empty lag value.
* scripts/gn-indexer-run.sh: --index=PATH-aware argument scan.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/gn-indexer-lag.sh25
-rwxr-xr-xscripts/gn-indexer-run.sh10
2 files changed, 32 insertions, 3 deletions
diff --git a/scripts/gn-indexer-lag.sh b/scripts/gn-indexer-lag.sh
index 64ec655..96d0813 100755
--- a/scripts/gn-indexer-lag.sh
+++ b/scripts/gn-indexer-lag.sh
@@ -15,7 +15,8 @@
 #   * mysql client: $GN4_INDEXER_LAG_MYSQL (else mysql -u USER -h HOST)
 #   * user/host:    GN4_INDEXER_LAG_USER (webqtlout) / _HOST (127.0.0.1)
 #   * database:     --db DB or GN4_INDEXER_LAG_DB
-#   * table prefix: GN4_INDEXER_DELTA_TABLE_PREFIX (test seam, direct)
+#   * table prefix: GN4_INDEXER_DELTA_TABLE_PREFIX (honoured only with
+#                   GN4_INDEXER_DELTA_TEST=1 — the test seam test seam)
 #   * state file:   $GN4_INDEXER_LAG_STATE else <index>.lag.state
 set -u
 
@@ -37,7 +38,6 @@ done
 
 sla_minutes=${GN4_INDEXER_LAG_SLA_MINUTES:-120}
 sla_seconds=$(( sla_minutes * 60 ))
-prefix=${GN4_INDEXER_DELTA_TABLE_PREFIX:-}
 state=${GN4_INDEXER_LAG_STATE:-${index}.lag.state}
 sidecar=${index}.sidecar.json
 
@@ -45,6 +45,16 @@ log() {
     echo "$(date -u +%Y-%m-%dT%H:%M:%SZ) gn-indexer-lag: $*"
 }
 
+# advisory A3(a): the table-prefix test seam is honoured only with the test seam
+# second opt-in; otherwise it is ignored (and noted) so a stray env var in
+# release cannot redirect the lag query.
+prefix=
+if [ "${GN4_INDEXER_DELTA_TEST:-0}" = "1" ]; then
+    prefix=${GN4_INDEXER_DELTA_TABLE_PREFIX:-}
+elif [ -n "${GN4_INDEXER_DELTA_TABLE_PREFIX:-}" ]; then
+    log "WARNING: ${GN4_INDEXER_DELTA_TABLE_PREFIX} set but ignored (test seam requires GN4_INDEXER_DELTA_TEST=1)"
+fi
+
 mysql_cmd=${GN4_INDEXER_LAG_MYSQL:-"mysql -u ${GN4_INDEXER_LAG_USER:-webqtlout} -h ${GN4_INDEXER_LAG_HOST:-127.0.0.1} --batch --skip-column-names"}
 if [ -n "$db" ]; then
     mysql_q() { $mysql_cmd "$db" -e "$1"; }
@@ -77,10 +87,21 @@ newest_change=$(mysql_q "SELECT MAX(ROW_START) FROM ( $union ) u" 2>/dev/null) |
     log "ERROR: lag query failed (mysql client or privileges?)"
     exit 1
 }
+# advisory A3(b): a literal NULL / empty MAX is "no change", not a gap.
+if [ "$newest_change" = "NULL" ]; then
+    newest_change=
+fi
 lag_seconds=$(mysql_q "SELECT TIMESTAMPDIFF(SECOND, '$marker', NOW(6))" 2>/dev/null) || {
     log "ERROR: lag arithmetic query failed"
     exit 1
 }
+# advisory A3(c): guard an empty / non-numeric lag before comparing.
+case "$lag_seconds" in
+    ''|*[!0-9-]*)
+        log "ERROR: lag_seconds not numeric ('${lag_seconds}')"
+        exit 1
+        ;;
+esac
 
 log "marker=$marker newest_change=${newest_change:-NULL} lag_seconds=$lag_seconds sla_seconds=$sla_seconds"
 
diff --git a/scripts/gn-indexer-run.sh b/scripts/gn-indexer-run.sh
index 8a33c45..6c3d5c9 100755
--- a/scripts/gn-indexer-run.sh
+++ b/scripts/gn-indexer-run.sh
@@ -44,9 +44,13 @@ case "$mode" in
 esac
 
 # Resolve --index from the remaining args (or GN4_INDEXER_INDEX).
+# Both `--index PATH` and `--index=PATH` are honoured.
 index=${GN4_INDEXER_INDEX:-}
 prev=
 for arg in "$@"; do
+    case "$arg" in
+        --index=*) index=${arg#--index=} ;;
+    esac
     if [ "$prev" = "--index" ]; then
         index=$arg
     fi
@@ -59,7 +63,11 @@ lock=${GN4_INDEXER_LOCK:-${index}.lock}
 held=${GN4_INDEXER_HELD:-${index}.lock.held}
 worst_case=${GN4_INDEXER_WORST_CASE_MINUTES:-99}
 
-# Hold the lock on fd 9 for the wrapper's lifetime (inherited by the child).
+# Hold the lock on fd 9 for the wrapper's lifetime. NOTE (test seam nit): on
+# dash a failed `exec 9>file` redirection exits the shell before the `||`
+# branch runs, so this `|| { ... }` is a safety net for shells that do
+# reach it; the failure is fatal either way (the lock is never silently
+# skipped).
 exec 9>"$lock" || {
     log "ERROR: cannot open lock file $lock"
     exit 1