Skip to content

Commit

Permalink
Consider true terminal statuses for billing cron (#11706)
Browse files Browse the repository at this point in the history
  • Loading branch information
JonsSpaghetti committed Mar 19, 2024
1 parent 6e67862 commit eb5fe35
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -480,9 +480,10 @@ private Set<Long> getEarlySyncJobsFromResult(final Result<Record> result) {
}

/**
* This query retrieves billable sync jobs (job status: INCOMPLETE, SUCCEEDED and CANCELLED) for
* connections that have been created in the past 7 days OR finds the first successful sync jobs for
* their corresponding connections. These results are used to mark these early syncs as free.
* This query retrieves billable sync jobs (jobs in a terminal status - succeeded, cancelled,
* failed) for connections that have been created in the past 7 days OR finds the first successful
* sync jobs for their corresponding connections. These results are used to mark these early syncs
* as free.
*/
private static final String EARLY_SYNC_JOB_QUERY =
// Find the first successful sync job ID for every connection.
Expand All @@ -500,7 +501,9 @@ private Set<Long> getEarlySyncJobsFromResult(final Result<Record> result) {
+ " FROM jobs j"
+ " LEFT JOIN connection c ON c.id = UUID(j.scope)"
+ " LEFT JOIN FirstSuccessfulJobIdByConnection min_j_ids ON j.id = min_j_ids.min_job_id"
+ " WHERE j.status IN ('succeeded', 'incomplete', 'cancelled')"
// Consider only jobs that are in a generally accepted terminal status
// io/airbyte/persistence/job/models/JobStatus.java:23
+ " WHERE j.status IN ('succeeded', 'cancelled', 'failed')"
+ " AND j.config_type = 'sync'"
+ " AND c.id IS NOT NULL"
// Keep a job if it was created within 7 days of its connection's creation,
Expand Down

0 comments on commit eb5fe35

Please sign in to comment.