Skip to content

fix(extension): skip MEOS timezone init when no zoneinfo on system (unblocks musl probe) - #182

Merged
estebanzimanyi merged 1 commit into
MobilityDB:mainfrom
estebanzimanyi:fix/meos-tz-init-resilient
Jul 29, 2026
Merged

fix(extension): skip MEOS timezone init when no zoneinfo on system (unblocks musl probe)#182
estebanzimanyi merged 1 commit into
MobilityDB:mainfrom
estebanzimanyi:fix/meos-tz-init-resilient

Conversation

@estebanzimanyi

Copy link
Copy Markdown
Member

Summary

Skip the MEOS meos_initialize_timezone("Europe/Brussels") call when /usr/share/zoneinfo isn't present on the system. This unblocks the musl probe (PR #172) without requiring a separate fix to the upstream extension-ci-tools Dockerfile.

Background

meos_initialize_timezone(...) calls into MEOS's pgtz code which opens /usr/share/zoneinfo to load the timezone database. On minimal containers (Alpine/musl, edge-device runtimes) tzdata is not installed by default, so the call surfaces:

could not open directory "/usr/share/zoneinfo": No such file or directory
could not open directory "/usr/share/zoneinfo": No such file or directory
make: *** [Makefile:36: test_release_internal] Error 1

…and the test runner downstream then errors. This was the exact failure mode on the musl probe (#172, linux_amd64_musl row) — MEOS C compiled+linked green, but the runtime timezone init failed.

The fix

Guard the meos_initialize_timezone call with a portable stat + S_IFDIR check on the canonical zoneinfo directory:

struct stat tz_st {};
if (stat("/usr/share/zoneinfo", &tz_st) == 0 && (tz_st.st_mode & S_IFDIR)) {
    meos_initialize_timezone("Europe/Brussels");
}

If zoneinfo isn't present, the extension loads against MEOS's default (UTC) instead of erroring at startup.

Behaviour matrix

Host Pre-fix Post-fix
Linux x86_64 (Ubuntu/manylinux2_28) with tzdata ✅ Brussels TZ ✅ Brussels TZ (unchanged)
Linux arm64 with tzdata ✅ Brussels TZ ✅ Brussels TZ (unchanged)
macOS with tzdata ✅ Brussels TZ ✅ Brussels TZ (unchanged)
musl/Alpine without tzdata ❌ "could not open directory" → tests fail ✅ UTC default; extension loads
Future edge-device runtimes Same failure mode ✅ Resilient

Alternative: upstream Dockerfile fix

The complementary fix is apk add tzdata in extension-ci-tools/docker/linux_amd64_musl/Dockerfile. Both unblock the musl probe; having both gives belt-and-suspenders coverage and lets the extension load on any tzdata-less host (not just the CI image).

The extension-side fix in this PR has the additional benefit that it makes MobilityDuck deployable on edge devices and minimal containers without requiring the operator to install tzdata.

Verification

Linux x86_64 build green (4 polyfills inherited from the substrate stack + 1 TZ-resilient commit):

$ cmake --build build/release --config Release --target mobilityduck_loadable_extension -- -j1
[72/72] Linking CXX shared library extension/mobilityduck/mobilityduck.duckdb_extension

$ ./build/release/duckdb -c "LOAD '...mobilityduck.duckdb_extension'; SELECT asText(TGEOGPOINT(ST_Point(1, 2), to_timestamp(946684800)));"
POINT(1 2)@2000-01-01 01:00:00+01

The Brussels TZ output is preserved on a host with zoneinfo present.

Refs

meos_initialize_timezone loads /usr/share/zoneinfo through MEOS's pgtz code,
which fails on opendir when the zoneinfo database is absent (Alpine/musl images,
minimal containers, edge devices), erroring the whole extension load. Guard the
call on the presence of /usr/share/zoneinfo so the extension loads against UTC
instead of failing at startup.
@estebanzimanyi
estebanzimanyi force-pushed the fix/meos-tz-init-resilient branch from 4ce3492 to 93cc2de Compare July 29, 2026 07:29
@estebanzimanyi
estebanzimanyi merged commit 7d07346 into MobilityDB:main Jul 29, 2026
17 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.

1 participant