Runs live, versioned Python application objects on one VM, with a suite of apps: projects, notes, tasks, files and more.

9 downloads

dbbasic-object-server/docs/migrating-from-object-primitive.md
Install on DigitalOcean Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/dbbasic-object-server.git
HTTPS
https://gitstable.com/git/askrobots/dbbasic-object-server.git
SSH
ssh://git@gitstable.com:2222/askrobots/dbbasic-object-server.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

Daniel Quellhorst Changelog for this batch. 65ef78d 3 hours, 18 minutes ago History
migrating-from-object-primitive.md · 5.4 KB · 102 lines

Migrating from the old object primitive server

scripts/migrate_from_object_primitive.py copies objects from the old askrobots object server ("multiplexing" 0.9.0) into this server.

Design: offline import

The tool reads the old server over HTTP (GET only; it can never write to it) and writes directly into the new server's objects dir and data dir while the new server is stopped. Why not the admin API: source creation there is gated behind DBBASIC_ENABLE_SOURCE_WRITES, stamps new timestamps and authors on every version, and cannot set state with the old types or preserve version ids. Writing the files directly keeps version ids, authors, messages and timestamps exactly, with no flags to flip. The cost: stop the new server first (the tool takes the state-file lock but is not coordinated with a running server's caches).

Run it

export DBBASIC_OLD_AUTH='Basic <base64 admin:password>'   # or: Token <t>
python scripts/migrate_from_object_primitive.py \
    --old-url http://old-host:8001 --auth-env DBBASIC_OLD_AUTH \
    --objects-dir ./objects --data-dir ./data            # dry run: writes nothing
python scripts/migrate_from_object_primitive.py ... --apply   # copy, then verify
  • Auth: the full Authorization header value comes from --auth-env NAME or

--auth-file PATH; never from argv, never printed or put in the report.

  • --only GLOB / --exclude GLOB (repeatable) match the object id or the old

path (tools_*, users/1/*).

  • --overwrite replaces objects whose target source, state or versions differ.

Without it those are reported as conflict and skipped.

  • --report FILE (default migration-report.json): the plan and verify results.
  • --rate-limit-wait SECONDS (default 300; 0 = never wait): the most time one

run spends waiting out the old server's rate limit. See below.

  • Exit code: 0 clean; 1 if any object errored or failed verification (a real

mismatch); 2 if the old server could not be listed; 3 if nothing mismatched but some objects could not be re-read to verify.

The old server's rate limit (HTTP 429)

The old server allows a fixed number of requests per minute per client address (1,000 by default) and answers the rest with HTTP 429, a Retry-After header and Rate limit exceeded. Try again in N seconds. One run makes a handful of requests per object plus one per stored version, and --apply reads every object twice (plan, then verify), so a dry run followed straight away by --apply can pass the limit part-way through.

The tool treats a 429 as "ask again later", never as an answer: it waits the time the answer gives (the header, else the text, else 5 seconds) plus one second, prints rate limited by the old server (HTTP 429); waiting Ns, and retries. The waits of one run add up against --rate-limit-wait. When the budget is spent:

  • while planning, the object is reported as error (`fetch failed: ... HTTP

429`) and is not written;

  • while verifying, the object is listed as COULD NOT VERIFY, counted

separately in verified N object(s): A match, B mismatch, C could not verify, and recorded under unverified in the report (not under verify). It was written but not compared. Run the same command again once the limit has passed: already-copied objects plan as identical and are verified.

Any other failure to re-read an object during verify (a timeout, HTTP 500) is reported the same way. MISMATCH now always means the tool read both sides and they differ.

Plan actions: create, identical (skipped), fill (source identical, target missing state/versions), conflict, overwrite, error.

What it copies

  • Current source, at the path this server derives from the object id

(users/<uid>/name.py for u_<uid>_name). Ownership is that layout.

  • State: all keys. Values are stored the way this server's state.tsv stores

them, so some types change: bools, objects and arrays are stored as JSON text (a bool reads back as the string "true"); a string that looks like a number reads back as a number. The dry run prints a note: for each such key. Values containing a tab or newline cannot be stored in state.tsv: that object is reported as error and not written. Per-key update timestamps are not exposed by the old API and are set to import time.

  • Versions: every version with its id, author, message and timestamp, plus

content (fetched per version with ?version=N).

  • After --apply, every object is re-fetched from the old server and compared

(source hash, state as this server reads it, version ids/hashes/authors/ messages/timestamps) against the target. An object that could not be re-fetched is reported as COULD NOT VERIFY, not as a match or a mismatch.

What it does not copy

  • Cluster/replication metadata, logs, source-change entries, users/accounts

and permissions: not exposed by the old object API. Recreate accounts here.

  • Files under the old data/files, collections, and anything else outside

/objects: not exposed, copy them by hand.

  • Objects the old server cannot load. The old server imports an object before

serving its source, so one with a missing dependency answers HTTP 500 for every read (seen in trial: tools_ocr, tools_ocr_easyocr, tools_orientation lacked pytesseract/easyocr). Fix the old environment or copy those files manually.

  • Objects whose id does not map to a public path here (e.g. views__create,

the _ prefix): reported as error.

  • Correlation ids on versions (not in the old API).