Merged
Conversation
Three bugs prevented journal archival from working on lplex-cloud: 1. Live JournalWriter had zero RotateDuration, so files never rotated and the on-rotate trigger never fired. Add -journal-rotate-duration flag (default PT1H) and thread it through InstanceManager to each instance's JournalConfig. 2. On startup, the keeper only archived files during hard-expire. If the process restarted with rotated but non-expired .lpj files missing .archived markers, they sat there until max-age. Add a one-shot archiveUnarchived() sweep at startup that archives any unarchived files (skipping the newest per dir as it may be the active writer). 3. (Already fixed externally) archive-to-s3.sh read .file instead of .path from the JSONL metadata.
The previous commit only threaded RotateDuration through to the cloud's JournalWriter. Add RotateSize too so files rotate on whichever threshold hits first (time or size), matching the boat-side behavior. Rename SetJournalRotateDuration to SetJournalRotation(duration, size) since both knobs travel together.
Three bugs prevented journal files from reaching S3: 1. Shutdown ordering: cancel() killed the keeper before im.Shutdown() stopped brokers. Journal finalize -> OnRotate fired into a dead keeper. Fix: shutdown servers, then brokers, then keeper. 2. stopBroker didn't wait for journal writer goroutine. finalize() and OnRotate ran asynchronously after stopBroker returned. Added journalDone channel so stopBroker blocks until finalize completes. 3. archiveUnarchived skipped the newest file per directory (assumed active). With only one file (common after short-lived deployments), nothing got archived. Since the sweep runs at startup before any brokers exist, all files are completed. Removed the skip entirely. Also added drain logic to keeper's Run() so it processes remaining rotation notifications after context cancellation.
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
JournalWriterinInstanceState.ensureBroker()had zeroRotateDuration, so files never rotated andon-rotatearchival never fired. Added-journal-rotate-durationflag (defaultPT1H) tolplex-cloud, threaded throughInstanceManager→InstanceState→JournalConfig.archiveUnarchived()toJournalKeeper.Run()that scans all directories on startup and archives any.lpjfiles missing.archivedmarkers (skipping the newest file per dir, which may be the active writer). Catches files missed due to crashes, restarts, or late archive configuration.lplex-cloud.conf.example, and README with the new flag and startup sweep behavior.-journal-rotate-duration PT1Hto the Docker entrypoint in the infra repo.Test plan
TestStartupArchivesUnarchivedFiles- non-archived files get archived on startup, newest skippedTestStartupSkipsAlreadyArchivedFiles- already-archived files aren't re-archivedTestStartupSkipsActiveFile- most recent file per dir is skippedTestCloudJournalWriterRotation- duration flows from IM to JournalWriter config, OnRotate firesTestSetJournalRotateDurationRetroactive- retroactive update of existing instancesgo build ./...golangci-lint run(0 issues)