Skip to content

Flaky test: basic_logging_functionality #1525

@jpnurmi

Description

@jpnurmi

basic_logging_functionality (test_logs.c) is flaky. It has been observed to fail 4 times in the past week on Android emulator CI jobs (API 31 and API 35). Retrying usually makes it pass.

test_logs.c:70: Check 2 == 0... failed    ← sentry_log_fatal() returned SENTRY_LOG_RETURN_FAILED
test_logs.c:75: Check 1 == 2... failed    ← called_count was 1, expected 2
Date Job Failed job
2026-02-17 Android (API 35, NDK 29) https://github.com/getsentry/sentry-native/actions/runs/22089794051/job/63832163517
2026-02-15 Android (API 31, NDK 27) https://github.com/getsentry/sentry-native/actions/runs/22035584524/job/63667828107
2026-02-13 Android (API 35, NDK 29) https://github.com/getsentry/sentry-native/actions/runs/21996918782/job/63559234113
2026-02-10 Android (API 35, NDK 29) https://github.com/getsentry/sentry-native/actions/runs/21859122255/job/63083295377

Details

The test fills the 5-slot batcher queue (SENTRY_BATCHER_QUEUE_LENGTH is 5 for unit tests), then calls sleep_ms(20) expecting the batcher thread to flush, before enqueuing a 6th log (fatal). The problem is that a timed sleep provides no ordering guarantee with respect to other threads — the batcher thread may not have been scheduled at all during that interval, or may still be mid-flush when the main thread resumes. Since sentry__batcher_enqueue retries only twice (ENQUEUE_MAX_RETRIES=2) with no backoff between attempts, all retries can exhaust instantly while the active buffer is still sealed. The fatal log is then dropped (SENTRY_LOG_RETURN_FAILED=2), and sentry_close() flushes only the original 5-item batch, yielding called_count=1 instead of 2.

Reproduced locally by pinning the test to a single CPU core under heavy system load (stress --cpu 8 --io 8 --vm 2 + taskset -c 0 nice -n 19): 16 failures out of 500 runs (3.2%).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions