Skip to content

CCIP-11513 hydrate Indexer with pending tasks#1130

Open
bukata-sa wants to merge 3 commits into
mainfrom
ccip-11513/indexer-hydrate
Open

CCIP-11513 hydrate Indexer with pending tasks#1130
bukata-sa wants to merge 3 commits into
mainfrom
ccip-11513/indexer-hydrate

Conversation

@bukata-sa
Copy link
Copy Markdown
Collaborator

@bukata-sa bukata-sa commented May 21, 2026

Description

Improves indexer restart reliability by hydrating the worker pool with messages that were already in PROCESSING state, so interrupted work can resume on startup.

Also adds storage support for fetching processing messages, updates task TTL handling so restored tasks keep the right deadline, refreshes tests/mocks, and includes a small logging cleanup.

Testing

  1. ccv up
  2. ccv test smoke-v3
  3. ccv db-shell indexer
  4. \c indexer-1
indexer-1=# select message_id, status from indexer.messages;
                             message_id                             | status  
--------------------------------------------------------------------+---------
 0xf4a32fae0be3623f78a0278a02dc55f8bc8803b1fd85842b3122eabe9344fb51 | SUCCESS
 0x4d84c4222dc080636baa67fd4bfdc3824b17485a02b8d3ef58d1a590f67be473 | SUCCESS
 0x08d24e8c33736f686164e933f04488d320d5adfacaf36417f4badcf82926adbc | SUCCESS
 0x1f8e09c575801270e4ed3fd6bb5eaa1025bd79102543d812c84020b2fdcd70b8 | SUCCESS
 0xd896313ac7886da4b186edb496315bb636412f6b02fecf0d813e7164732e520e | SUCCESS
(5 rows)
indexer-1=# update indexer.messages set status='PROCESSING';
UPDATE 5
indexer-1=# select message_id, status from indexer.messages;
                             message_id                             |   status   
--------------------------------------------------------------------+------------
 0xf4a32fae0be3623f78a0278a02dc55f8bc8803b1fd85842b3122eabe9344fb51 | PROCESSING
 0x08d24e8c33736f686164e933f04488d320d5adfacaf36417f4badcf82926adbc | PROCESSING
 0x1f8e09c575801270e4ed3fd6bb5eaa1025bd79102543d812c84020b2fdcd70b8 | PROCESSING
 0x4d84c4222dc080636baa67fd4bfdc3824b17485a02b8d3ef58d1a590f67be473 | PROCESSING
 0xd896313ac7886da4b186edb496315bb636412f6b02fecf0d813e7164732e520e | PROCESSING
(5 rows)
  1. docker restart
indexer-1=# select message_id, status from indexer.messages;
                             message_id                             | status  
--------------------------------------------------------------------+---------
 0xf4a32fae0be3623f78a0278a02dc55f8bc8803b1fd85842b3122eabe9344fb51 | SUCCESS
 0x4d84c4222dc080636baa67fd4bfdc3824b17485a02b8d3ef58d1a590f67be473 | SUCCESS
 0x08d24e8c33736f686164e933f04488d320d5adfacaf36417f4badcf82926adbc | SUCCESS
 0x1f8e09c575801270e4ed3fd6bb5eaa1025bd79102543d812c84020b2fdcd70b8 | SUCCESS
 0xd896313ac7886da4b186edb496315bb636412f6b02fecf0d813e7164732e520e | SUCCESS
(5 rows)

Checklist

  • Breaking changes documented in changelog (see changelog directory)
  • Cross link related PRs (in this or other repositories)
  • just lint fix - no new lint errors
  • just generate - mocks and protobufs are up to date

Comment thread indexer/pkg/worker/worker_pool.go Outdated
Message: msg.Message,
MessageCCVAddresses: msg.MessageCCVAddresses,
}
task, err := NewTask(p.logger, vr, p.registry, p.storage, msg.Metadata.IngestionTimestamp.Add(p.scheduler.VerificationVisibilityWindow()))
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to continue same TTL I call IngestionTimestamp + VerificationVisibilityWindow

}
p.logger.Infow("Enqueueing new Message", "messageID", message.VerifierResult.MessageID.String())
task, err := NewTask(p.logger, message.VerifierResult, p.registry, p.storage, p.scheduler.VerificationVisibilityWindow())
task, err := NewTask(p.logger, message.VerifierResult, p.registry, p.storage, message.Metadata.IngestionTimestamp.Add(p.scheduler.VerificationVisibilityWindow()))
Copy link
Copy Markdown
Collaborator Author

@bukata-sa bukata-sa May 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we here also need to use IngestionTimestamp + VerificationVisibilityWindow
IngestionTimestamp is the right timestamp (NTP-provided) for Task lifetime

@bukata-sa bukata-sa force-pushed the ccip-11513/indexer-hydrate branch from 61d8140 to 55777b8 Compare May 21, 2026 16:06
@bukata-sa bukata-sa force-pushed the ccip-11513/indexer-hydrate branch from 55777b8 to 9750311 Compare May 21, 2026 16:33
@bukata-sa bukata-sa marked this pull request as ready for review May 21, 2026 18:46
@bukata-sa bukata-sa requested a review from a team as a code owner May 21, 2026 18:46
Copilot AI review requested due to automatic review settings May 21, 2026 18:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves indexer restart reliability by hydrating the worker pool on startup with messages already persisted in PROCESSING state, allowing interrupted work to resume. It also adjusts task TTL handling to preserve the original ingestion-based deadline when tasks are restored or enqueued.

Changes:

  • Added storage support to fetch PROCESSING messages and hydrate them into the worker scheduler on startup.
  • Changed worker task construction to use an absolute TTL timestamp (derived from ingestion time + visibility window) instead of computing TTL from time.Now().
  • Updated tests/mocks and improved worker logging to use structured fields.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/mocks/mock_IndexerStorage.go Adds mock support for the new GetProcessingMessages storage method.
indexer/pkg/worker/worker.go Switches verifier summary logging to structured Infow.
indexer/pkg/worker/worker_pool.go Hydrates pending PROCESSING messages from storage into the scheduler on startup; updates TTL handling for newly discovered messages.
indexer/pkg/worker/worker_pool_test.go Updates tests for ingestion-based TTL and adds coverage for hydration behavior.
indexer/pkg/worker/task.go Changes NewTask to accept an absolute TTL (time.Time) and preserves it across retries/restores.
indexer/pkg/worker/task_test.go Updates task tests to use the new absolute TTL signature.
indexer/pkg/storage/postgres.go Implements GetProcessingMessages query for PROCESSING messages.
indexer/pkg/common/storage.go Extends the storage interface with GetProcessingMessages.
Files not reviewed (1)
  • internal/mocks/mock_IndexerStorage.go: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread indexer/pkg/worker/worker_pool.go Outdated
Comment thread indexer/pkg/worker/worker_pool_test.go Outdated
carte7000
carte7000 previously approved these changes May 21, 2026
Comment thread indexer/pkg/worker/worker_pool.go Outdated
@bukata-sa bukata-sa requested a review from a team as a code owner May 22, 2026 08:52
@bukata-sa bukata-sa force-pushed the ccip-11513/indexer-hydrate branch 5 times, most recently from b5d491b to 6bb8c78 Compare May 22, 2026 11:05
@bukata-sa bukata-sa force-pushed the ccip-11513/indexer-hydrate branch from 6bb8c78 to 74cd32f Compare May 22, 2026 11:12
@github-actions
Copy link
Copy Markdown

Code coverage report:

Package main ccip-11513/indexer-hydrate Diff
github.com/smartcontractkit/chainlink-ccv/aggregator 49.35% 49.35% +0.00%
github.com/smartcontractkit/chainlink-ccv/bootstrap 54.14% 54.14% +0.00%
github.com/smartcontractkit/chainlink-ccv/cli 65.13% 65.13% +0.00%
github.com/smartcontractkit/chainlink-ccv/cmd 15.54% 15.54% +0.00%
github.com/smartcontractkit/chainlink-ccv/common 56.54% 56.54% +0.00%
github.com/smartcontractkit/chainlink-ccv/executor 45.97% 45.97% +0.00%
github.com/smartcontractkit/chainlink-ccv/indexer 36.57% 37.53% +0.96%
github.com/smartcontractkit/chainlink-ccv/integration 45.84% 45.84% +0.00%
github.com/smartcontractkit/chainlink-ccv/pkg 84.62% 84.62% +0.00%
github.com/smartcontractkit/chainlink-ccv/pricer 0.00% 0.00% +0.00%
github.com/smartcontractkit/chainlink-ccv/protocol 65.88% 65.88% +0.00%
github.com/smartcontractkit/chainlink-ccv/verifier 34.48% 34.48% +0.00%
Total 46.40% 46.40% +0.00%

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants