Activecontext: Log queue_name and preprocessor on processing error
What does this MR do and why?
Adds the queue_name and preprocessor information in the logged fields when an error occurs during the ActiveContext (Semantic Search) indexing process.
This will allow us to correlate errors with their source queue (i.e., the main Code queue or RetryQueue) and preprocessor, so we can understand the full picture of failures.
Code changes
- Queue options
ActiveContext::Queuebase class:- always set the
queue_nameinpreprocess_options - add an
extra_preprocess_optionsfor child classes to override
- always set the
- Have child queue classes override
extra_preprocess_optionsinstead of thepreprocess_options
- Reference processing
- In error handling blocks: accept a
queue_nameandpreprocessor, to be logged on errors - In
fetch_contentandapply_embeddingsmethods:- accept a
queue_nameparameter - pass
queue_nameandpreprocessorto error handling blocks
- accept a
- In the actual reference class (
Ai::ActiveContext::References::Code)- make sure the processor blocks accept the
queue_nameparameter - pass the
queue_nameto the preprocessor methods (fetch_contentandapply_embeddings)
- make sure the processor blocks accept the
- When items are picked up from a queue for bulk processing, the queue
preprocess_options(includingqueue_name) will be passed to the reference preprocessor (see code)
- In error handling blocks: accept a
Process flow
- The
BulkProcessWorkeris triggered and callsActiveContext::BulkProcessQueue.process!for each registered queue ActiveContext::BulkProcessQueuepicks up items for processing, making aReferenceobject out of each itemActiveContext::BulkProcessQueueprocesses the references withReference.preprocess_references(refs, **queue.preprocess_options)- the
queue.preprocess_optionswill includequeue_name
- the
- The references' preprocessor blocks are ran (defined in
Ai::ActiveContext::References::Code)- the
Ai::ActiveContext::References::Codepreprocessors acceptsqueue_nameand passes them to the actual preprocessor methods - the preprocessor methods (
fetch_contentandapply_embeddings) passes thequeue_nameandpreprocessorto the error-handling blocks - in the error-handling block, the
queue_nameandpreprocessorare logged on errors
- the
References
- Issue: #604054 (closed)
Screenshots or screen recordings
N/A
How to set up and validate locally
We just need to check that the queue_name and preprocessor fields are logged when an error occurs in the ActiveContext bulk processing pipeline.
-
Ensure that the ActiveContext
BulkProcessWorkercan run-
OR comment out the check preventing the
BulkProcessWorkerfrom running:diff --git a/gems/gitlab-active-context/lib/active_context/concerns/bulk_async_process.rb b/gems/gitlab-active-context/lib/active_context/concerns/bulk_async_process.rb index 723ac5011998..4041c6a1a500 100644 --- a/gems/gitlab-active-context/lib/active_context/concerns/bulk_async_process.rb +++ b/gems/gitlab-active-context/lib/active_context/concerns/bulk_async_process.rb @@ -11,7 +11,7 @@ module BulkAsyncProcess extend ActiveSupport::Concern def perform(*args) - return false unless ActiveContext.indexing? + # return false unless ActiveContext.indexing? if args.empty? enqueue_all_shards
-
Add a dummy item to the
Codequeue:::Ai::ActiveContext::Collections::Code.track_refs!(routing: "1", hashes: ["one"]) -
Run the bulk processing
::Ai::ActiveContext::BulkProcessWorker.new.perform("Ai::ActiveContext::Queues::Code", 0) -
This should result in an error, logged with
queue_nameandpreprocessorinformation:# in GitLab root directory, run: tail -f log/active_context.log # expected error log { "severity":"WARN", "time":"2026-07-16T05:27:08.633Z", "correlation_id":"c5bf3282a2deffa90c69c4948bbc470a", "exception_class":"<exception class>", "exception_message":"<exception message>", "exception_backtrace":["backtrace here"], "class_name":"Class", "queue_name":"code", # new field "preprocessor":"content_fetcher", # new field "infinite_retry":false, # new field "reference":"Ai::ActiveContext::References::Code|5|1|one", "reference_id":"one" }
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Related to #604054 (closed)