Skip to content

Commit 0d710d7

Browse files
authored
[cuebot] Make Satisfy depend adhere to depend config (#2352)
The satisfy logic that runs to clean up stale depends would catch both EATEN and SUCCESS frames as a sign its dependents should be cleaned, but this behavior is only acceptable when `depend.satisfy_only_on_frame_success` is false. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes * **New Features** * Added `depend.satisfy_only_on_frame_success` configuration flag to control how EATEN frames are treated during dependency recovery. When enabled (default), only SUCCEEDED frames satisfy dependencies; when disabled, EATEN frames also count as completion. <!-- review_stack_entry_start --> [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/AcademySoftwareFoundation/OpenCue/pull/2352?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) <!-- review_stack_entry_end --> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent bb6bd61 commit 0d710d7

3 files changed

Lines changed: 44 additions & 19 deletions

File tree

cuebot/src/main/java/com/imageworks/spcue/dao/MaintenanceDao.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,12 @@ public interface MaintenanceDao {
7171
* failures.
7272
*
7373
* @param limit maximum number of depend IDs to return
74+
* @param includeEatenAsComplete when true, EATEN frames count as completion alongside
75+
* SUCCEEDED; when false, only SUCCEEDED frames satisfy dependencies (matches the
76+
* {@code depend.satisfy_only_on_frame_success} runtime behavior)
7477
* @return list of pk_depend values for stale active depends
7578
*/
76-
List<String> findStaleDependIds(int limit);
79+
List<String> findStaleDependIds(int limit, boolean includeEatenAsComplete);
7780

7881
/**
7982
* Fixes frames stuck in DEPEND state by setting int_depend_count to 0 for frames that have no

cuebot/src/main/java/com/imageworks/spcue/dao/postgres/MaintenanceDaoJdbc.java

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -95,20 +95,29 @@ public void recalculateSubscriptions() {
9595

9696
// spotless:off
9797
/**
98-
* Finds active, non-composite depends whose depended-upon entity has already completed
99-
* successfully. Composite depends (b_composite = true) are parent depends that are
100-
* automatically satisfied when all their child depends are satisfied, so they should
101-
* not be resolved directly.
98+
* Finds active, non-composite depends whose depended-upon entity has already completed.
99+
* Composite depends (b_composite = true) are parent depends that are automatically
100+
* satisfied when all their child depends are satisfied, so they should not be resolved
101+
* directly.
102102
*
103-
* Section 1: Job-level depends (JOB_ON_JOB, LAYER_ON_JOB, FRAME_ON_JOB) where
104-
* every frame in the depended-upon job has SUCCEEDED or been EATEN.
103+
* The set of frame states that count as completion is selected by
104+
* {@code includeEatenAsComplete}: SUCCEEDED only, or SUCCEEDED+EATEN. This mirrors the
105+
* runtime behavior gated by {@code depend.satisfy_only_on_frame_success} in
106+
* {@code FrameCompleteHandler}.
107+
*
108+
* Section 1: Job-level depends (JOB_ON_JOB, LAYER_ON_JOB, FRAME_ON_JOB) where every
109+
* frame in the depended-upon job is in a completion state.
105110
* Section 2: Layer-level depends (JOB_ON_LAYER, LAYER_ON_LAYER, FRAME_ON_LAYER) where
106-
* every frame in the depended-upon layer has SUCCEEDED or been EATEN.
111+
* every frame in the depended-upon layer is in a completion state.
107112
* Section 3: Frame-level depends (JOB_ON_FRAME, LAYER_ON_FRAME, FRAME_ON_FRAME) where
108-
* the specific depended-upon frame has SUCCEEDED or been EATEN.
113+
* the specific depended-upon frame is in a completion state.
109114
*/
110-
private static final String FIND_STALE_DEPEND_IDS =
111-
// Section 1: Job-level depends where all frames in the job succeeded or were eaten.
115+
private static String buildFindStaleDependIdsSql(boolean includeEatenAsComplete) {
116+
String completeStates = includeEatenAsComplete
117+
? "('SUCCEEDED', 'EATEN')"
118+
: "('SUCCEEDED')";
119+
return
120+
// Section 1: Job-level depends where all frames in the job completed.
112121
// Pre-filter on job.str_state = 'FINISHED' leverages the i_job_str_state index to
113122
// skip depends on active jobs. A FINISHED job may still have DEAD frames, so we
114123
// also verify frame states via NOT EXISTS.
@@ -122,11 +131,11 @@ public void recalculateSubscriptions() {
122131
+ "AND NOT EXISTS ("
123132
+ "SELECT 1 FROM frame f "
124133
+ "WHERE f.pk_job = d.pk_job_depend_on "
125-
+ "AND f.str_state NOT IN ('SUCCEEDED', 'EATEN')) "
134+
+ "AND f.str_state NOT IN " + completeStates + ") "
126135

127136
+ "UNION ALL "
128137

129-
// Section 2: Layer-level depends where all frames in the layer succeeded or were eaten.
138+
// Section 2: Layer-level depends where all frames in the layer completed.
130139
+ "SELECT pk_depend FROM depend d "
131140
+ "WHERE d.b_active = true "
132141
+ "AND d.b_composite = false "
@@ -135,11 +144,11 @@ public void recalculateSubscriptions() {
135144
+ "AND NOT EXISTS ("
136145
+ "SELECT 1 FROM frame f "
137146
+ "WHERE f.pk_layer = d.pk_layer_depend_on "
138-
+ "AND f.str_state NOT IN ('SUCCEEDED', 'EATEN')) "
147+
+ "AND f.str_state NOT IN " + completeStates + ") "
139148

140149
+ "UNION ALL "
141150

142-
// Section 3: Frame-level depends where the specific frame succeeded or was eaten.
151+
// Section 3: Frame-level depends where the specific frame completed.
143152
+ "SELECT pk_depend FROM depend d "
144153
+ "WHERE d.b_active = true "
145154
+ "AND d.b_composite = false "
@@ -148,14 +157,22 @@ public void recalculateSubscriptions() {
148157
+ "AND EXISTS ("
149158
+ "SELECT 1 FROM frame f "
150159
+ "WHERE f.pk_frame = d.pk_frame_depend_on "
151-
+ "AND f.str_state IN ('SUCCEEDED', 'EATEN')) "
160+
+ "AND f.str_state IN " + completeStates + ") "
152161

153162
+ "LIMIT ?";
163+
}
164+
165+
private static final String FIND_STALE_DEPEND_IDS_INCLUDING_EATEN =
166+
buildFindStaleDependIdsSql(true);
167+
private static final String FIND_STALE_DEPEND_IDS_SUCCEEDED_ONLY =
168+
buildFindStaleDependIdsSql(false);
154169
// spotless:on
155170

156171
@Override
157-
public List<String> findStaleDependIds(int limit) {
158-
return getJdbcTemplate().queryForList(FIND_STALE_DEPEND_IDS, String.class, limit);
172+
public List<String> findStaleDependIds(int limit, boolean includeEatenAsComplete) {
173+
String sql = includeEatenAsComplete ? FIND_STALE_DEPEND_IDS_INCLUDING_EATEN
174+
: FIND_STALE_DEPEND_IDS_SUCCEEDED_ONLY;
175+
return getJdbcTemplate().queryForList(sql, String.class, limit);
159176
}
160177

161178
// spotless:off

cuebot/src/main/java/com/imageworks/spcue/service/MaintenanceManagerSupport.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,14 @@ public void recoverStuckDependencies() {
272272
try {
273273
int batchSize = env.getProperty("maintenance.stuck_dependency_recovery_batch_size",
274274
Integer.class, 1000);
275+
// Mirror FrameCompleteHandler's runtime behavior: when this flag is true (default)
276+
// EATEN frames must not satisfy dependencies, so they are excluded from the sweep.
277+
boolean satisfyOnlyOnFrameSuccess =
278+
env.getProperty("depend.satisfy_only_on_frame_success", Boolean.class, true);
275279

276280
// Phase 1: Satisfy stale active depends through normal code path
277-
List<String> staleDependIds = maintenanceDao.findStaleDependIds(batchSize);
281+
List<String> staleDependIds =
282+
maintenanceDao.findStaleDependIds(batchSize, !satisfyOnlyOnFrameSuccess);
278283
int satisfiedCount = 0;
279284
for (String dependId : staleDependIds) {
280285
try {

0 commit comments

Comments
 (0)