Skip to content

fix(perf): drop unconditional debug logs from the MagicMapper hot path - #2323

Merged
rubenvdlinde merged 1 commit into
developmentfrom
fix/magicmapper-hot-path-debug-logs
Aug 4, 2026
Merged

fix(perf): drop unconditional debug logs from the MagicMapper hot path#2323
rubenvdlinde merged 1 commit into
developmentfrom
fix/magicmapper-hot-path-debug-logs

Conversation

@rubenvdlinde

Copy link
Copy Markdown
Contributor

Second half of the runaway-log fix (#2320 was the first).

Removing the two calls from isFileProperty() cut the log rate from ~1 GB/min to ~0.7 GB/min — still enough to fill a disk mid-upgrade, because four more handlers log on every query.

Sampled from a live log, the top writers were:

handler line frequency
MagicStatisticsHandler "Set critical metadata field" per field, per row
MagicTableHandler "Table existence check: cache hit" per query
MagicRbacHandler "CLI/system context — bypassing RBAC filter" per query, on every background job's path
MagicOrganizationHandler "CLI/system context — skipping org filter" per query

The rule applied: a debug log that fires unconditionally on a hot path tells you nothing a single trace would not, while costing a line per call forever. A log that fires on an unusual branch is a real signal.

Removed: cache hit, cache miss, CLI-context bypass, admin bypass, filter applied, org lookups returned, row converted, metadata field set, entity state.

Kept — every one rare, every one about a decision that matters:

  • Authorization unresolvable; clamping query to deny-all (fail-closed)
  • Action not configured on a non-empty authorization block — failing closed
  • No access conditions met, denying all
  • Array operand for a scalar comparison operator — emitting an impossible predicate
  • Could not determine the database platform — defaulting to MariaDB syntax

Nothing about RBAC or organisation enforcement changes; only whether the handler narrates itself on paths where the answer was never in doubt.

phpcs and phpmd clean on lib/Db/MagicMapper; 1358 Db tests, 4308 assertions.

Second half of the runaway-log fix. Removing the two calls from
isFileProperty() cut the rate from ~1 GB/min to ~0.7 GB/min — still enough to
fill a disk mid-upgrade, because four more handlers log on every query.

Sampled from a live log, the top writers were: MagicStatisticsHandler "Set
critical metadata field" (per field, per row), MagicTableHandler "Table
existence check: cache hit" (per query), and the MagicRbacHandler /
MagicOrganizationHandler "CLI/system context" lines (per query, on the path
every background job takes).

The rule applied: a debug log that fires UNCONDITIONALLY on a hot path tells you
nothing a single trace would not, while costing a line per call forever. A log
that fires on an unusual branch is a real signal.

So these go — cache hit, cache miss, CLI-context bypass, admin bypass, filter
applied, org lookups returned, row converted, metadata field set, entity state.

And these stay, all of them rare and all of them about a decision that matters:
  "Authorization unresolvable; clamping query to deny-all (fail-closed)"
  "Action not configured on a non-empty authorization block — failing closed"
  "No access conditions met, denying all"
  "Array operand for a scalar comparison operator — emitting an impossible predicate"
  "Could not determine the database platform — defaulting to MariaDB syntax"

Nothing about RBAC or organisation ENFORCEMENT changes here; only whether the
handler narrates itself on paths where the answer was never in doubt.

phpcs and phpmd clean on lib/Db/MagicMapper; 1358 Db tests, 4308 assertions.
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Quality Report — ConductionNL/openregister @ 2383305

Check PHP Vue Security License Tests
lint
phpcs
phpmd
psalm
phpstan
phpmetrics
eslint
stylelint
build
composer ✅ 173/173
npm ✅ 713/713
PHPUnit
Newman
Playwright

Quality workflow — 2026-08-04 05:28 UTC

Download the full PDF report from the workflow artifacts.

@rubenvdlinde
rubenvdlinde merged commit fd8d987 into development Aug 4, 2026
30 checks passed
@rubenvdlinde
rubenvdlinde deleted the fix/magicmapper-hot-path-debug-logs branch August 4, 2026 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant