Repository navigation
fix(aws): pagination がスパースな時間範囲で取りこぼす問題を修正 - #29
Merged
Merged
Conversation
GetLogEvents を時間範囲チャンキングで並列化した v1.4.1 で、 89MB → 15KB と大量にイベントを取りこぼす問題があった。 根本原因: paginateGetLogEvents の終端条件に len(out.Events) == 0 が含まれて おり、AWS が pagination 途中で「空イベント + 新しい NextForwardToken」 を返した時点で end-of-stream と誤判定して打ち切っていた。 AWS CLI ドキュメントは次の通り明記している: > The CloudWatch Logs service will sometimes (especially during periods > of low or no activity) return an empty list of events even if you > have not reached the end of the stream's log events. In this case, > the operation returns nextForwardToken in the response, and you > should call get-log-events again with this token. 時間チャンキングを入れたことで各チャンクがスパースな時間窓を見るよう になり、空ページが頻発して大量のロスが顕在化した。floci は密に返す ためローカルでは再現せず、実 AWS でのみ発現していた。 修正: - len(out.Events) == 0 を終端条件から削除 - nextToken == prevToken のみで終端判定(AWS 仕様準拠) - 既存テスト TestClient_GetLogEvents_PaginationStopsOnEmptyPage を 「空ページを跨いで続行」する新仕様のテストに置き換え Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
v1.4.1 で導入した時間範囲チャンキング並列フェッチで、実 AWS 環境では 89MB → 15KB と大量のイベントを取りこぼす致命的な問題があった。本 PR で根本原因を修正。
根本原因
`paginateGetLogEvents` の終端条件に `len(out.Events) == 0` が含まれており、AWS が pagination 途中で「空イベント + 新しい NextForwardToken」を返した時点で end-of-stream と誤判定して打ち切っていた。
AWS CLI ドキュメントは次の通り明記:
時間チャンキングを入れたことで各チャンクがスパースな時間窓を見るようになり、空ページが頻発して大量のロスが顕在化した。floci は密に返すためローカルでは再現せず、実 AWS でのみ発現。
Changes
Test plan
v1.4.1 の扱い
proxy.golang.org がキャッシュ済みのため `@v1.4.1` を引くと壊れたコードが取れます。次リリースで `go.mod` に以下の retract を入れるのが安全:
```
retract v1.4.1 // pagination prematurely truncates over sparse time windows (#?)
```
🤖 Generated with Claude Code