Repository navigation
Conversation
CydeWeys
force-pushed
the
bsa-explicit-stage-fsm
branch
from
November 27, 2026 20:30
6d1ca35 to
8c2de6c
Compare
CydeWeys
enabled auto-merge
December 4, 2026 20:04
CydeWeys
force-pushed
the
bsa-explicit-stage-fsm
branch
3 times, most recently
from
December 4, 2026 20:33
5503198 to
770023f
Compare
BSA download and refresh pipelines currently rely on ordinal Enum.compareTo checks for stage advancement, silently discard updated schedule state mid-run, miscompute maxNopInterval on retried downloads, ignore non-2xx daily upload failures, and retry permanent 4xx HTTP responses as if they were transient. These gaps allow illegal transitions such as DONE -> NOP and stage skips, risk wiping previous completed download metadata, hide failed daily uploads behind success notifications, and burn retry budgets under the global BSA lock on permanent client errors. Replacing ordinal comparisons with explicit transition tables and fixing the state-handling and HTTP classification bugs ensures every BSA stage transition is validated, stale schedule handles cannot overwrite a concurrent worker's progress, metadata and checksums stay consistent across download stages, failed daily uploads surface immediately, and permanent 4xx responses fail fast without starving retries. Changes: - Replace ordinal Enum.compareTo checks in DownloadSchedule and RefreshSchedule with explicit ImmutableMultimap allowed-transition tables, forbid DONE -> NOP and illegal stage skips, verify the persisted DB stage still matches this.stage() to reject stale schedule handles, fix the swapped format arguments in transition verification messages, and preserve latestCompleted and alwaysDownload when returning updated schedules. - Capture returned schedules across stage transitions in BsaDownloadAction and BsaRefreshAction so in-memory stage and metadata stay synchronized with persisted state. - Fix DownloadScheduler to evaluate maxNopInterval against the previous completed job rather than the in-progress job when resuming downloads. - Inspect HTTP response status via Response.isSuccessful() in UploadBsaUnavailableDomainsAction so non-2xx responses fail and report errors (sanitizing CR/LF characters before logging at SEVERE), and move ReservedList.loadReservedLists outside replicaTm().transact(...) to avoid nesting primary tm() cache-miss transactions inside replica transactions. - Classify HTTP status codes in BsaException.isRetriableHttpStatus (retrying 408, 429, and 5xx while failing fast on permanent 4xx and unexpected status codes) across BsaReportSender, BlockListFetcher, and BsaCredential, guard getResponseMessage() against IOException across all three clients and disconnect in a finally block in BlockListFetcher.tryFetch, sanitize CR/LF characters when logging BSA report responses to prevent log injection, and log non-retriable BsaExceptions at SEVERE in BsaDownloadAction and BsaRefreshAction. - Add unit and functional tests covering all legal/illegal stage transitions, stale schedule rejection, metadata preservation, resumed maxNopInterval checks, non-2xx daily uploads, non-nested reserved-list loading, 4xx vs 5xx retry classification, BlockListFetcher disconnect ordering and cleanup, and log-injection sanitization. BUG= http://b/591075515
CydeWeys
force-pushed
the
bsa-explicit-stage-fsm
branch
from
December 4, 2026 20:51
770023f to
a79566a
Compare
This branch has not been deployed
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.
BSA download and refresh pipelines currently rely on ordinal
Enum.compareTochecks for stage advancement, silently discard updated schedule state mid-run, miscomputemaxNopIntervalon retried downloads, ignore non-2xx daily upload failures, and retry permanent 4xx HTTP responses as if they were transient. These gaps allow illegal transitions such asDONE -> NOPand stage skips, risk wiping previous completed download metadata, hide failed daily uploads behind success notifications, and burn retry budgets under the global BSA lock on permanent client errors.Replacing ordinal comparisons with explicit transition tables and fixing the state-handling and HTTP classification bugs ensures every BSA stage transition is validated, stale schedule handles cannot overwrite a concurrent worker's progress, metadata and checksums stay consistent across download stages, failed daily uploads surface immediately, and permanent 4xx responses fail fast without starving retries.
Changes
Enum.compareTochecks inDownloadScheduleandRefreshSchedulewith explicitImmutableMultimapallowed-transition tables, forbidDONE -> NOPand illegal stage skips, verify the persisted DB stage still matchesthis.stage()to reject stale schedule handles, fix the swapped format arguments in transition verification messages, and preservelatestCompletedandalwaysDownloadwhen returning updated schedules.BsaDownloadActionandBsaRefreshActionso in-memory stage and metadata stay synchronized with persisted state.DownloadSchedulerto evaluatemaxNopIntervalagainst the previous completed job rather than the in-progress job when resuming downloads.Response.isSuccessful()inUploadBsaUnavailableDomainsActionso non-2xx responses fail and report errors (sanitizing CR/LF characters before logging atSEVERE), and moveReservedList.loadReservedListsoutsidereplicaTm().transact(...)to avoid nesting primarytm()cache-miss transactions inside replica transactions.BsaException.isRetriableHttpStatus(retrying408,429, and5xxwhile failing fast on permanent4xxand unexpected status codes) acrossBsaReportSender,BlockListFetcher, andBsaCredential, guardgetResponseMessage()againstIOExceptionacross all three clients and disconnect in afinallyblock inBlockListFetcher.tryFetch, sanitize CR/LF characters when logging BSA report responses to prevent log injection, and log non-retriableBsaExceptions atSEVEREinBsaDownloadActionandBsaRefreshAction.maxNopIntervalchecks, non-2xx daily uploads, non-nested reserved-list loading,4xxvs5xxretry classification,BlockListFetcherdisconnect ordering and cleanup, and log-injection sanitization.BUG= http://b/591075515
This change is