Skip to content

Feature request: bound log-tail throttling backoff and recover the polling interval #9403

Open

Description

@vinsymoyya

Describe your idea/feature/enhancement

Make sam logs --tail recover predictably after throttling, for both CloudWatch Logs and X-Ray data. The current pollers repeatedly square their interval: starting from the default one second, five consecutive throttles produce delays of 2, 4, 16, 256, 65536 seconds. A successful poll does not restore the original interval, so transient throttling can leave a live tail effectively stalled.

Proposal

  • Double the interval after each throttle, with a 60-second ceiling.
  • Restore the configured interval after a successful poll, including a successful empty response.
  • Preserve explicitly configured intervals longer than 60 seconds by using the larger of 60 seconds and that interval as the ceiling.
  • Apply the same policy to CloudWatch Logs, X-Ray traces and X-Ray service graphs. This needs no SAM Spec or CLI option changes.

With the default interval, sustained throttling would wait 2, 4, 8, 16, 32, 60, 60, ... seconds. A successful poll would resume the one-second interval.

Additional Details

Reproduced at 9e92728fe6e965bfa9e4cfa3151adf9c9f1f9de3 without AWS calls or actual sleeping:

from unittest.mock import Mock, patch
from botocore.exceptions import ClientError
from samcli.lib.observability.cw_logs.cw_log_puller import CWLogPuller

puller = CWLogPuller(Mock(), Mock(), "log-group", max_retries=5)
throttled = ClientError({"Error": {"Code": "ThrottlingException"}}, "FilterLogEvents")
with patch.object(puller, "load_time_period", side_effect=throttled):
    with patch("samcli.lib.observability.cw_logs.cw_log_puller.time.sleep") as sleep:
        puller.tail()
        print([entry.args[0] for entry in sleep.call_args_list])

Current output: [2, 4, 16, 256, 65536]. The final delay alone is over 18 hours. The X-Ray base poller has the same delay logic.

The proposed ceiling is for the tailer's polling loop, in addition to any retries performed inside the AWS SDK. Verification can use simulated throttle/success responses and a patched clock; no live service load is needed.

Activity

  1. vinsymoyya commented on Nov 5, 2026

    @vinsymoyya
    ContributorAuthor

    Opened #9404 with bounded doubling backoff for CloudWatch and X-Ray tailing, plus restoration of the configured interval after successful polls. Eight new regression cases cover sustained throttling, recovery and custom intervals. The full make pr run passed with 9,766 tests and 94.09% coverage.

  2. vinsymoyya commented on Nov 9, 2026

    @vinsymoyya
    ContributorAuthor

    Opened #9413 as a follow-up to the review of #9404. It recognizes X-Ray's actual ThrottledException (HTTP 429), so trace and service-graph tails back off instead of terminating.

    The PR adds botocore Stubber coverage for GetTraceSummaries, BatchGetTraces, and GetServiceGraph, verifies that access denied after a throttle raises without another sleep across all three pullers, and clarifies the retry warnings. Full Linux make pr passed with 9,777 tests and 94.14% coverage; the resolved combination with #9404 also passed 179 affected tests locally.

    #9404 remains the bounded-backoff change. #9413 targets current develop independently; its description notes the small conflict resolution needed when combining the two. Interruptible waits remain separate.

  3. bnusunny commented on Nov 13, 2026

    @bnusunny
    Contributor

    Thanks for the precise repro. Squaring the interval on every throttle (2→4→16→256→65536 s) is clearly unintended, and doubling with a cap plus resetting on success is the right fix. We'll review #9404 first and then #9413, which depends on it in practice. We'll check that the merged pair keeps an explicit --interval above 60 s working as you described.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions