Skip to content

[Java] TaskInitializer.init() returns before model results are loaded; no readiness signal #17

Open

Description

@mpc00620

Problem

The javadoc of TaskInitializer.init() says it "Initializes and executes all tasks in both stages", and the call blocks. However:

  • the model-result and bloom-filter tasks only schedule themselves (task/dataloading/ModelResultPeriodicLoadingTask.java:93, BloomFilterPeriodicLoadingTask.java:102);
  • their first run happens after a random delay of up to one full period (task/PeriodicTaskWithRandomizedStart.java:84), which is 300 s by default.

Until that first run, every evaluation sees no model and fails open. The README works around this with Thread.sleep(10000), which does not actually guarantee anything. There is also no API to ask whether DTE has loaded its data.

Proposed fix

  • init() runs the first load of the model-result and bloom-filter tasks before returning, within the existing overall.execution-timeout, and then continues periodic refresh with the existing randomized schedule.
  • Add boolean isReady() to BidRequestEvaluatorFactory, which is true once the configurations, the registries and the first model load have completed.
  • Remove the Thread.sleep(10000) advice from the README.

Compatibility

init() keeps its signature and timeout bound but may take longer to return, because it now does what its javadoc promises. isReady() is additive.

Test

Before the fix: immediately after init() returns (with a fake S3 that holds model data), the model cache is empty. After the fix: it is populated, and isReady() is true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions