Skip to content

Conversation

@akshayutture-augment
Copy link

@akshayutture-augment akshayutture-augment commented Nov 14, 2025

Test 10


Replicated from ai-code-review-evaluation/grafana-cursor#10


Note

Centralizes ResourceServer initialization (init at construction, reordered startup), improves search index tracing/logging and Bleve cache locking, and skips a flaky Postgres test.

  • Storage Server:
    • Initialize server during construction (NewResourceServer) and remove per-request Init calls across CRUD, List, Watch, Search, History, Origin, Health, and Blob methods.
    • Reorder startup: build search index before starting the watcher.
  • Search/Indexing:
    • Propagate tracer context in searchSupport.init and build; add startup log with duration_secs and total_docs.
    • Replace deprecated logger usage with s.log.Warn.
    • Bleve: narrow cache locking to assignment only; minor TODO cleanup.
  • SQL Backend:
    • Use tracer-returned context in GetResourceStats span.
  • Tests:
    • Skip integration test on Postgres in CI; add explanatory TODO.

Written by Cursor Bugbot for commit d762a96. Configure here.

…#97529)

* dont lazy init unified storage

* Inits index when creating new resource server. Fixes trace propagation by passing span ctx. Update some logging.

* Use finer grained cache locking when building indexes to speed things up. Locking the whole function was slowing things down.

* formatting

* linter fix

* go mod

* make update-workspace

* fix workspaces check error

* update dependency owner in mod file

* wait 1 second before querying metrics

* try with big timeout, see if fixes CI. Wont fail locally.

* skips postgres integration test. Only fails in drone. Will fix later.

* put delay back to 500 ms
@akshayutture-augment
Copy link
Author

cursor review


b.cacheMu.Lock()
b.cache[key] = idx
b.cacheMu.Unlock()
Copy link

Choose a reason for hiding this comment

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

Bug: Race Condition: Unnecessary Index Generation

Moving the mutex lock to after index building creates a race condition where multiple goroutines can concurrently build the same index for the same key. All goroutines will perform the expensive index building work, then race to write to the cache. The lock needs to protect the entire check-and-build operation to prevent duplicate work and ensure only one index is built per key.

Fix in Cursor Fix in Web

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.

3 participants