Skip to content

feat(config): warn about legacy Postgres env var usage - #3151

Merged
CommanderStorm merged 13 commits into
maplibre:mainfrom
reddynitish:fix-1052-warn-legacy-env-vars
Aug 24, 2026
Merged

feat(config): warn about legacy Postgres env var usage#3151
CommanderStorm merged 13 commits into
maplibre:mainfrom
reddynitish:fix-1052-warn-legacy-env-vars

Conversation

@reddynitish

Copy link
Copy Markdown
Contributor

Summary

Warns once at startup when Martin falls back to one of the five implicit Postgres env vars (DATABASE_URL, DEFAULT_SRID, PGSSLCERT, PGSSLKEY, PGSSLROOTCERT), naming the config-file key (and CLI flag, where one exists) that replaces it. Split out of #3141 following review from @CommanderStorm, alongside #3150 (the --ssl-cert/--ssl-key flags).

This is a deprecation/migration-warning PR only — all five variables still function exactly as before. The actual breaking removal is deferred to Martin v2 and is not part of this PR.

  • A variable the config file already references explicitly as ${VAR} is not reported — it's doing exactly what it should.
  • Variable values are never logged, only the fact that a var is set.
  • Warning text names the replacement, it never claims the variable is already ignored.
  • docs/content/env-vars.md gets a short deprecation note pointing at Remove automatic ENV var usage except inside config files #1052.

Testing

  • cargo fmt --check
  • cargo check --workspace
  • cargo test -p martin --lib config::file::main::parse (63 passed)
  • cargo test -p martin --lib config::args::root (9 passed, including a regression test that DATABASE_URL still configures Postgres while also warning)
  • cargo clippy -p martin --all-targets -- -D warnings — passes for the changed crate; a pre-existing result_large_err clippy failure in martin-core::tiles::postgres::errors (unrelated file, present on main) blocks a full clean workspace clippy run.

DATABASE_URL, DEFAULT_SRID, PGSSLCERT, PGSSLKEY and PGSSLROOTCERT are
still read implicitly, but Martin now warns once at startup for each one
that is set, naming the config-file key (and CLI flag, where one exists)
that replaces it. A variable the config file already references via
${VAR} is not reported. Values are never logged.

Existing implicit env-var behavior is unchanged: DATABASE_URL etc. still
configure Postgres exactly as they do today, with or without a config
file. This is a step toward maplibre#1052 without the breaking removal.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
MartinBuilder::with_postgres connects via the DATABASE_URL env var,
the same pattern just start/just test-pg use. The new deprecation
warning from warn_legacy_env_vars fires on every such test and was
tripping assert_log_clean.
@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown

Performance Comparison mainfix-1052-warn-legacy-env-vars

Total Elapsed Time: 106.99s → 109.57s (+2.4%)
CPU Baseline: 91.34µs → 91.45µs (+0.1%)
Benchmark ID: timing

timing - Function execution time metrics.

+----------------------------+------------------------------+---------------------------------+---------------------------------+---------------------------------+------------------------------+
| Function                   | Calls                        | Avg                             | P95                             | Total                           | % Total                      |
+----------------------------+------------------------------+---------------------------------+---------------------------------+---------------------------------+------------------------------+
| martin::main               | 1 → 1 (+0.0%)                | 106.97s → 109.57s (+2.4%)       | 107.04s → 109.59s (+2.4%)       | 106.97s → 109.57s (+2.4%)       | 100.00% → 100.00% (+0.0%)    |
+----------------------------+------------------------------+---------------------------------+---------------------------------+---------------------------------+------------------------------+
| martin::start              | 1 → 1 (+0.0%)                | 106.97s → 109.54s (+2.4%)       | 106.97s → 109.59s (+2.4%)       | 106.97s → 109.54s (+2.4%)       | 99.99% → 99.97% (-0.0%)      |
+----------------------------+------------------------------+---------------------------------+---------------------------------+---------------------------------+------------------------------+
| content::get_tile          | 3200800 → 3200800 (+0.0%)    | 16.32µs → 17.23µs (+5.6%)       | 27.84µs → 28.98µs (+4.1%)       | 52.24s → 55.16s (+5.6%)         | 48.83% → 50.34% (+3.1%)      |
+----------------------------+------------------------------+---------------------------------+---------------------------------+---------------------------------+------------------------------+
| content::get_http_response | 2200600 → 2200600 (+0.0%)    | 17.31µs → 18.29µs (+5.7%)       | 34.24µs → 34.78µs (+1.6%)       | 38.10s → 40.25s (+5.6%)         | 35.61% → 36.73% (+3.1%)      |
+----------------------------+------------------------------+---------------------------------+---------------------------------+---------------------------------+------------------------------+
| content::get_tile_content  | 2200600 → 2200600 (+0.0%)    | 15.09µs → 15.99µs (+6.0%)       | 32.34µs → 32.86µs (+1.6%)       | 33.21s → 35.20s (+6.0%)         | 31.04% → 32.12% (+3.5%)      |
+----------------------------+------------------------------+---------------------------------+---------------------------------+---------------------------------+------------------------------+
| content::recompress        | 2200600 → 2200600 (+0.0%)    | 2.09µs → 2.15µs (+2.9%)         | 71.00ns → 81.00ns (+14.1%)      | 4.59s → 4.74s (+3.3%)           | 4.29% → 4.33% (+0.9%)        |
+----------------------------+------------------------------+---------------------------------+---------------------------------+---------------------------------+------------------------------+
| content::encode            | 100100 → 100100 (+0.0%)      | 44.54µs → 46.35µs (+4.1%)       | 71.61µs → 73.98µs (+3.3%)       | 4.46s → 4.64s (+4.0%)           | 4.17% → 4.23% (+1.4%)        |
+----------------------------+------------------------------+---------------------------------+---------------------------------+---------------------------------+------------------------------+
| content::new               | 3200800 → 3200800 (+0.0%)    | 1.36µs → 1.43µs (+5.1%)         | 1.94µs → 1.86µs (-4.1%)         | 4.35s → 4.58s (+5.3%)           | 4.06% → 4.18% (+3.0%)        |
+----------------------------+------------------------------+---------------------------------+---------------------------------+---------------------------------+------------------------------+
| source::get_sources        | 3200800 → 3200800 (+0.0%)    | 1.13µs → 1.23µs (+8.8%)         | 1.69µs → 1.63µs (-3.6%)         | 3.63s → 3.93s (+8.3%)           | 3.39% → 3.59% (+5.9%)        |
+----------------------------+------------------------------+---------------------------------+---------------------------------+---------------------------------+------------------------------+
| pool::detect_format        | 15 → 15 (+0.0%)              | 4.59ms → 4.84ms (+5.4%)         | 5.73ms → 6.88ms (+20.1%) ⚠️     | 68.84ms → 72.61ms (+5.5%)       | 0.06% → 0.07% (+16.7%)       |
+----------------------------+------------------------------+---------------------------------+---------------------------------+---------------------------------+------------------------------+
| pool::get_metadata         | 15 → 15 (+0.0%)              | 3.59ms → 4.01ms (+11.7%)        | 4.55ms → 5.90ms (+29.7%) ⚠️     | 53.89ms → 60.17ms (+11.7%)      | 0.05% → 0.05% (+0.0%)        |
+----------------------------+------------------------------+---------------------------------+---------------------------------+---------------------------------+------------------------------+
| metadata::get_metadata     | 15 → 15 (+0.0%)              | 3.25ms → 3.88ms (+19.4%)        | 4.31ms → 5.82ms (+35.0%) ⚠️     | 48.75ms → 58.20ms (+19.4%)      | 0.05% → 0.05% (+0.0%)        |
+----------------------------+------------------------------+---------------------------------+---------------------------------+---------------------------------+------------------------------+
| validation::detect_format  | 15 → 15 (+0.0%)              | 2.50ms → 2.64ms (+5.6%)         | 3.63ms → 3.96ms (+9.1%)         | 37.55ms → 39.67ms (+5.6%)       | 0.04% → 0.04% (+0.0%)        |
+----------------------------+------------------------------+---------------------------------+---------------------------------+---------------------------------+------------------------------+
| pool::open_readonly        | 15 → 15 (+0.0%)              | 1.72ms → 1.42ms (-17.4%)        | 2.40ms → 1.92ms (-20.0%)        | 25.79ms → 21.27ms (-17.5%)      | 0.02% → 0.02% (+0.0%)        |
+----------------------------+------------------------------+---------------------------------+---------------------------------+---------------------------------+------------------------------+
| server::new_server         | 1 → 1 (+0.0%)                | 299.36µs → 241.88µs (-19.2%)    | 299.52µs → 241.92µs (-19.2%)    | 299.36µs → 241.88µs (-19.2%)    | 0.00% → 0.00% (+0.0%)        |
+----------------------------+------------------------------+---------------------------------+---------------------------------+---------------------------------+------------------------------+

alloc-bytes - Exclusive allocation bytes by each function (excluding nested calls).

+----------------------------+------------------------------+--------------------------------+--------------------------------+--------------------------------+----------------------------+
| Function                   | Calls                        | Avg                            | P95                            | Total                          | % Total                    |
+----------------------------+------------------------------+--------------------------------+--------------------------------+--------------------------------+----------------------------+
| content::get_tile_content  | 2200600 → 2200600 (+0.0%)    | 96.0 KB → 96.0 KB (+0.0%)      | 184.9 KB → 184.9 KB (+0.0%)    | 201.6 GB → 201.6 GB (+0.0%)    | 84.26% → 84.26% (+0.0%)    |
+----------------------------+------------------------------+--------------------------------+--------------------------------+--------------------------------+----------------------------+
| content::encode            | 100100 → 100100 (+0.0%)      | 344.6 KB → 344.6 KB (+0.0%)    | 347.2 KB → 347.2 KB (+0.0%)    | 32.9 GB → 32.9 GB (+0.0%)      | 13.75% → 13.75% (+0.0%)    |
+----------------------------+------------------------------+--------------------------------+--------------------------------+--------------------------------+----------------------------+
| source::get_sources        | 3200800 → 3200800 (+0.0%)    | 1.1 KB → 1.1 KB (+0.0%)        | 2.4 KB → 2.4 KB (+0.0%)        | 3.5 GB → 3.5 GB (+0.0%)        | 1.47% → 1.47% (+0.0%)      |
+----------------------------+------------------------------+--------------------------------+--------------------------------+--------------------------------+----------------------------+
| content::get_tile          | 3200800 → 3200800 (+0.0%)    | 287 B → 287 B (+0.0%)          | 296 B → 296 B (+0.0%)          | 876.6 MB → 876.6 MB (+0.0%)    | 0.36% → 0.36% (+0.0%)      |
+----------------------------+------------------------------+--------------------------------+--------------------------------+--------------------------------+----------------------------+
| content::get_http_response | 2200600 → 2200600 (+0.0%)    | 183 B → 183 B (+0.0%)          | 216 B → 216 B (+0.0%)          | 385.1 MB → 385.1 MB (+0.0%)    | 0.16% → 0.16% (+0.0%)      |
+----------------------------+------------------------------+--------------------------------+--------------------------------+--------------------------------+----------------------------+
| martin::start              | 1 → 1 (+0.0%)                | 3.2 MB → 3.2 MB (+0.0%)        | 3.2 MB → 3.2 MB (+0.0%)        | 3.2 MB → 3.2 MB (+0.0%)        | 0.00% → 0.00% (+0.0%)      |
+----------------------------+------------------------------+--------------------------------+--------------------------------+--------------------------------+----------------------------+
| validation::detect_format  | 15 → 15 (+0.0%)              | 82.0 KB → 82.2 KB (+0.2%)      | 531.0 KB → 531.5 KB (+0.1%)    | 1.2 MB → 1.2 MB (+0.0%)        | 0.00% → 0.00% (+0.0%)      |
+----------------------------+------------------------------+--------------------------------+--------------------------------+--------------------------------+----------------------------+
| pool::open_readonly        | 15 → 15 (+0.0%)              | 12.0 KB → 11.9 KB (-0.8%)      | 12.0 KB → 12.0 KB (+0.0%)      | 179.3 KB → 179.0 KB (-0.2%)    | 0.00% → 0.00% (+0.0%)      |
+----------------------------+------------------------------+--------------------------------+--------------------------------+--------------------------------+----------------------------+
| martin::main               | 1 → 1 (+0.0%)                | 171.3 KB → 171.3 KB (+0.0%)    | 171.4 KB → 171.4 KB (+0.0%)    | 171.3 KB → 171.3 KB (+0.0%)    | 0.00% → 0.00% (+0.0%)      |
+----------------------------+------------------------------+--------------------------------+--------------------------------+--------------------------------+----------------------------+
| metadata::get_metadata     | 15 → 15 (+0.0%)              | 6.4 KB → 6.4 KB (+0.0%)        | 17.0 KB → 17.0 KB (+0.0%)      | 96.0 KB → 96.2 KB (+0.2%)      | 0.00% → 0.00% (+0.0%)      |
+----------------------------+------------------------------+--------------------------------+--------------------------------+--------------------------------+----------------------------+
| pool::detect_format        | 15 → 15 (+0.0%)              | 2.9 KB → 3.0 KB (+3.4%)        | 3.0 KB → 3.0 KB (+0.0%)        | 44.1 KB → 45.3 KB (+2.7%)      | 0.00% → 0.00% (+0.0%)      |
+----------------------------+------------------------------+--------------------------------+--------------------------------+--------------------------------+----------------------------+
| server::new_server         | 1 → 1 (+0.0%)                | 31.3 KB → 31.3 KB (+0.0%)      | 31.3 KB → 31.3 KB (+0.0%)      | 31.3 KB → 31.3 KB (+0.0%)      | 0.00% → 0.00% (+0.0%)      |
+----------------------------+------------------------------+--------------------------------+--------------------------------+--------------------------------+----------------------------+
| pool::get_metadata         | 15 → 15 (+0.0%)              | 1.8 KB → 1.8 KB (+0.0%)        | 1.8 KB → 1.8 KB (+0.0%)        | 26.7 KB → 26.7 KB (+0.0%)      | 0.00% → 0.00% (+0.0%)      |
+----------------------------+------------------------------+--------------------------------+--------------------------------+--------------------------------+----------------------------+
| content::decode            | 1 → 1 (+0.0%)                | 0 B → 0 B (+0.0%)              | 0 B → 0 B (+0.0%)              | 0 B → 0 B (+0.0%)              | 0.00% → 0.00% (+0.0%)      |
+----------------------------+------------------------------+--------------------------------+--------------------------------+--------------------------------+----------------------------+
| content::new               | 3200800 → 3200800 (+0.0%)    | 0 B → 0 B (+0.0%)              | 0 B → 0 B (+0.0%)              | 0 B → 0 B (+0.0%)              | 0.00% → 0.00% (+0.0%)      |
+----------------------------+------------------------------+--------------------------------+--------------------------------+--------------------------------+----------------------------+

Threads

Total Alloc: 259.8 GB → 260.1 GB (+0.1%)
Total Dealloc: 259.8 GB → 260.2 GB (+0.2%)
Mem Diff: -53.1 MB → -53.1 MB (+0.0%)

+----------+----------------------------+------------------------------+------------------------------+--------------------------------+----------------------------------+
| Thread   | CPU % Avg                  | CPU % Max                    | Alloc                        | Dealloc                        | Mem Diff                         |
+----------+----------------------------+------------------------------+------------------------------+--------------------------------+----------------------------------+
| hp-debug | 1.80% → 2.40% (+33.3%) ⚠️  | 7.90% → 15.80% (+100.0%) ⚠️  | 10.3 KB → 10.3 KB (+0.0%)    | 299.7 MB → 299.6 MB (-0.0%)    | -299.6 MB → -299.6 MB (+0.0%)    |
+----------+----------------------------+------------------------------+------------------------------+--------------------------------+----------------------------------+

Generated with hotpath-rs

Comment thread docs/content/env-vars.md Outdated
Updated the environment variables documentation to remove deprecated variables and clarify usage. Added a warning about deprecated environment variables.
Comment thread e2e-tests/src/martin.rs Outdated
@reddynitish

Copy link
Copy Markdown
Contributor Author

@CommanderStorm Thanks for the earlier review. I addressed the feedback and rechecked the final diff/tests; #3151 is ready for another look when you have time.

@CommanderStorm CommanderStorm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cleaned it up a bit, lgtm now

@CommanderStorm
CommanderStorm enabled auto-merge (squash) August 24, 2026 13:11
autofix-ci Bot and others added 2 commits August 24, 2026 13:16
The docker-image e2e job only forwarded an explicit allowlist of env
vars into the container, so legacy_postgres_env_vars_warn_in_the_log's
DEFAULT_SRID never reached the process and its deprecation warning was
never logged.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@CommanderStorm
CommanderStorm merged commit b77491b into maplibre:main Aug 24, 2026
50 checks passed
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.

2 participants