fix(stats): fall back after full sync failure (#41411)
This commit is contained in:
committed by
GitHub
parent
38e10eb140
commit
0bff28de09
@@ -9,7 +9,7 @@ import { Effect, Layer } from "effect"
|
|||||||
import * as Context from "effect/Context"
|
import * as Context from "effect/Context"
|
||||||
import { Resource } from "sst/resource"
|
import { Resource } from "sst/resource"
|
||||||
|
|
||||||
const ATHENA_MAX_POLL_ATTEMPTS = 300
|
const ATHENA_MAX_POLL_ATTEMPTS = 900
|
||||||
const ATHENA_PAGE_SIZE = 1000
|
const ATHENA_PAGE_SIZE = 1000
|
||||||
|
|
||||||
export type AthenaData = Record<string, string>
|
export type AthenaData = Record<string, string>
|
||||||
|
|||||||
@@ -19,9 +19,19 @@ const daemon = Effect.gen(function* () {
|
|||||||
let lastFullDay = ""
|
let lastFullDay = ""
|
||||||
const pass = Effect.gen(function* () {
|
const pass = Effect.gen(function* () {
|
||||||
const today = new Date().toISOString().slice(0, 10)
|
const today = new Date().toISOString().slice(0, 10)
|
||||||
const full = lastFullDay !== today
|
if (lastFullDay !== today) {
|
||||||
yield* syncStats({ full })
|
const completed = yield* syncStats({ full: true }).pipe(
|
||||||
if (full) lastFullDay = today
|
Effect.as(true),
|
||||||
|
Effect.catchCause((cause) =>
|
||||||
|
Effect.logWarning(`full stats sync failed; falling back to incremental sync ${Cause.pretty(cause)}`).pipe(
|
||||||
|
Effect.as(false),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
lastFullDay = today
|
||||||
|
if (completed) return
|
||||||
|
}
|
||||||
|
yield* syncStats({ full: false })
|
||||||
}).pipe(
|
}).pipe(
|
||||||
Effect.catchCause((cause) =>
|
Effect.catchCause((cause) =>
|
||||||
Effect.logWarning(`stats sync failed ${JSON.stringify({ cause: Cause.pretty(cause) })}`),
|
Effect.logWarning(`stats sync failed ${JSON.stringify({ cause: Cause.pretty(cause) })}`),
|
||||||
|
|||||||
Reference in New Issue
Block a user