Sfoglia il codice sorgente

fix: host-build.sh stopped silently after installing the client

`libdir="$(cd "$PREFIX" && ls -d lib64 lib 2>/dev/null | head -1)"` - the
prefix has lib64 and no lib, so ls exits 2 for the missing operand.
2>/dev/null hid the message but not the status, and under
`set -euo pipefail` the command substitution aborted the script right
there: after the client was installed, before the relocatable
smartbotic-db-clientConfig.cmake was written and before vectorapi was
built. It printed nothing at all.

So --client was doing half its job in silence: a correctly installed
client, no CMake package, no vectorapi build. Found while building a
pre-release database client, where it looked like the client had not
been rebuilt. Replaced with a directory test, which cannot fail.

Worth noting what went wrong in diagnosing it, because both checks
were bad. I first concluded the script "exits 0 on failure" - that 0
was a background task's exit code, from a command ending in `tail`.
And I "proved" a stale client by grepping the installed header for a
string that only ever existed in server code, so the grep could not
have shown anything either way. The check that works, used
afterwards, is diffing the installed header against the source
checkout being built.

Also records that the apt repo now indexes every published version.
That gotcha said old versions became uninstallable on publish, which
was never retention but indexing: dpkg-scanpackages emits one version
per package without -m, while the pool had kept every .deb all along.
Fixed in the deb-repo tooling; the trixie index went from 33 stanzas
to 1191. Verified from prod: madison lists 0.8.0-1 back to 0.3.0-1, a
simulated downgrade of all three packages to 0.7.1-1 resolves, and a
plain install still picks the newest. A real rollback needs
--allow-downgrades and must move the three packages together.
fszontagh 1 mese fa
parent
commit
aa0e8f29aa
2 ha cambiato i file con 8 aggiunte e 2 eliminazioni
  1. 1 1
      CLAUDE.md
  2. 7 1
      scripts/host-build.sh

+ 1 - 1
CLAUDE.md

@@ -100,7 +100,7 @@ docker run -d --name svapi-dev -p 8080:8080 -e SMARTBOTIC_VECTORAPI_KEY=dev svap
 - **`--rebuild-base` is required when `DB_CLIENT_VERSION` moves.** The client version is baked into the Docker BASE image, so bumping the variable alone leaves the release build compiling against the old headers - it fails on the new entry points, or worse, silently links the old ones. Note `devstack/run-tests.sh` installs the client debs explicitly, so the TEST path can be on a newer client than the RELEASE path: a green suite is not evidence about the packages.
 - **`systemctl start` on an already-running unit is a no-op.** A package postinst starts the service, so any config written AFTER apt needs a `restart`, not a `start` - otherwise the process keeps the config that existed at install time and the file on disk disagrees with the running state. Compare the file mtime against `systemctl show -p ActiveEnterTimestamp` when a setting appears not to apply.
 - **Client ABI pin:** the server deb is compiled against `DB_CLIENT_VERSION` (`packaging/Dockerfile.base`). Every 2.x client shares one SONAME, so a deb built against a newer client installs fine and only segfaults on the next restart - keep the pin equal to the deploy target, and ship a DB upgrade and a vectorapi rebuild together.
-- **The apt repo drops superseded versions on publish**, so `pkg=<old version>` is uninstallable afterwards. Old `.deb`s survive in `$DEB_REPO_DIR/dist`; `build.sh` vendors the pinned client from there into `packaging/vendor/`, and a prod rollback needs them scp'd to the target first.
+- **The apt repo now indexes EVERY published version, so a rollback is an ordinary apt command.** It used to list only the newest, which made `pkg=<old version>` uninstallable the moment anything newer was published - and that was never retention, only indexing: `dpkg-scanpackages` emits one version per package unless given `-m`, while the pool had kept every `.deb` all along (a publish reported "3 added, 309 unchanged"). Fixed 2026-10-08 in the deb-repo tooling; the trixie index went from 33 stanzas to 1191. **A downgrade needs `--allow-downgrades`** (`apt-get install --allow-downgrades pkg=0.7.1-1 ...`), and downgrade the three app packages TOGETHER or apt resolves a split version set. A plain `apt install pkg` still picks the newest, so ordinary installs are unaffected. The backup step still stages the installed `.deb`s out of `/var/cache/apt/archives/`, which stays the right belt-and-braces for a rollback when the repo itself is unreachable.
 - **"The dev host cannot build the C++" was a misdiagnosis - it was a stale `protoc`.** The host builds everything natively; use `scripts/host-build.sh`. The old symptom was real: generated protos wanted `google/protobuf/map_field_inl.h`, a header protobuf 35 removed. But nothing in the database's tree includes that header - an **old protoc emits the include**. The host had libprotobuf 35.1 and gRPC 1.83 from the distro, and a hand-dropped static **protoc 25.2 in `~/.local/bin`** shadowing everything, while the distro's compiler package (`protobuf-35.1`, separate from `protobuf-devel`, which ships no protoc) was never installed. `find_program(PROTOC protoc REQUIRED)` took the 25.2 binary from PATH, generated code for a protobuf 25 runtime and compiled it against 35 headers. With a matching protoc the client and all of vectorapi compile and link natively. `host-build.sh` therefore picks protoc **by version rather than PATH order** and refuses to run on a mismatch, because the failure otherwise surfaces as a missing header deep in generated code rather than as a version complaint.
 - **`FailedPrecondition` means three different things** and must be branched on `FailureDetail.reason`: `missing_parent` and `delete_restricted` are 422, `read_only` is **503**, and an absent or unrecognised reason is **500**, never a guessed 422. Mapping the bare code to 422 told a caller that a read-only database was its own validation mistake, so it would fix its payload and retry forever instead of waiting. Use the `FailureDetail&` overloads wherever a call offers one - the reason-less `Failure` form cannot tell these apart.
 - **A version conflict is `ErrorCode::Aborted`** (client 2.12.0) carrying `currentVersion`, and maps to **409** `version_conflict`. It used to arrive as `Unknown` and fold into 503 "retry as-is", which is the opposite of the required instruction: re-read first. Never match on the message text for this.

+ 7 - 1
scripts/host-build.sh

@@ -86,7 +86,13 @@ if (( WITH_CLIENT )); then
     # `cmake --install` ships the library and headers but no CMake package, so
     # find_package(smartbotic-db-client) would fail: only the .deb carries a
     # config, written by the database's create-debs.sh. Write a relocatable one.
-    libdir="$(cd "$PREFIX" && ls -d lib64 lib 2>/dev/null | head -1)"
+    # NOT `ls -d lib64 lib`: ls exits 2 when either name is absent, and under
+    # `set -euo pipefail` that aborted the script HERE - silently, after the
+    # client was already installed, so the config below was never written and
+    # the vectorapi build never ran. The failure printed nothing at all, which
+    # is the worst way for a build script to stop.
+    libdir=lib64
+    [[ -d "$PREFIX/lib64" ]] || libdir=lib
     mkdir -p "$PREFIX/$libdir/cmake/smartbotic-db-client"
     cat > "$PREFIX/$libdir/cmake/smartbotic-db-client/smartbotic-db-clientConfig.cmake" <<'EOF'
 # Host build of smartbotic-db-client, not the Debian package. Relocatable: