Skip to content
This repository was archived by the owner on Sep 11, 2025. It is now read-only.

Conversation

@mattjohnsonpint
Copy link
Contributor

  • Remove the batching logic and background worker for writing inference history
  • Misc refactoring

Fixes #927. The issue was related to the batch not being thread safe, and having multiple triggers that could happen concurrently.

@mattjohnsonpint mattjohnsonpint requested review from a team and Copilot July 10, 2025 04:52
@linear
Copy link

linear bot commented Jul 10, 2025

Copy link
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 removes the previous batching worker for inference history and switches to immediate writes, refactors database writer functions, standardizes the ModusDB engine variable naming, and updates the changelog.

  • Drop batching logic and write inference history directly to the database
  • Rename GlobalModusDbEngine to globalModusDbEngine and update usages
  • Split and refactor write routines for ModusDB and Postgres, and revise WritePluginInfo

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
runtime/metrics/metrics.go Removed DroppedInferencesNum metric registration
runtime/db/modusdb.go Lowercased globalModusDbEngine variable and updated references
runtime/db/inferencehistory.go Eliminated batch writer; inlined direct DB writes; refactored write functions
runtime/db/db.go Removed background worker, simplified pool init with getPool
runtime/db/agentstate.go Updated ModusDB engine references to globalModusDbEngine
CHANGELOG.md Added fix: write inference history directly [#938]
Comments suppressed due to low confidence (3)

runtime/db/inferencehistory.go:306

  • There are no unit tests covering writeInferenceHistoryToPostgresDB. Adding targeted tests can help ensure correct SQL generation and error handling.
func writeInferenceHistoryToPostgresDB(ctx context.Context, data inferenceHistory) error {

runtime/db/inferencehistory.go:151

  • Consider adding tests for writePluginInfoToModusDB to verify that plugin metadata is correctly serialized and errors are handled gracefully.
func writePluginInfoToModusDB(ctx context.Context, plugin *plugins.Plugin) error {

runtime/db/inferencehistory.go:235

  • Switching from batched, asynchronous writes to synchronous writes on each inference may introduce latency under high load. Consider benchmarking the impact or reintroducing a bounded batch or queue to smooth out spikes.
func WriteInferenceHistory(ctx context.Context, model *manifest.ModelInfo, input, output any, start, end time.Time) {

@mattjohnsonpint mattjohnsonpint merged commit ba9a685 into main Jul 10, 2025
33 checks passed
@mattjohnsonpint mattjohnsonpint deleted the mjp/mod-9-invalid-json-data-when-saving-inference-history branch July 10, 2025 04:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Invalid JSON data when saving inference history

2 participants