Skip to content

[receiver/sqlserver] Use a shared database connection pool across scrapers#49606

Draft
singhvibhanshu wants to merge 26 commits into
open-telemetry:mainfrom
singhvibhanshu:47219
Draft

[receiver/sqlserver] Use a shared database connection pool across scrapers#49606
singhvibhanshu wants to merge 26 commits into
open-telemetry:mainfrom
singhvibhanshu:47219

Conversation

@singhvibhanshu

Copy link
Copy Markdown
Member

Description

This PR aims at making the SQL Server Receiver share a single database across all its scrapers. More info here.

Link to tracking issue

Fixes #47219

Testing

Added

Documentation

Added the chagelog file

Authorship

  • [WOOT] I, a human, wrote this pull request description myself.

Signed-off-by: singhvibhanshu <find.vibhanshu@gmail.com>
@singhvibhanshu
singhvibhanshu requested review from a team and crobert-1 as code owners July 10, 2026 15:07
@github-actions github-actions Bot added receiver/sqlserver Run Windows Enable running windows test on a PR labels Jul 10, 2026
@singhvibhanshu

Copy link
Copy Markdown
Member Author

/rerun

@singhvibhanshu

Copy link
Copy Markdown
Member Author

/rerun

Signed-off-by: singhvibhanshu <find.vibhanshu@gmail.com>
Signed-off-by: singhvibhanshu <find.vibhanshu@gmail.com>
Signed-off-by: singhvibhanshu <find.vibhanshu@gmail.com>
Signed-off-by: singhvibhanshu <find.vibhanshu@gmail.com>
Comment thread receiver/sqlserverreceiver/factory.go
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Jul 13, 2026

Copy link
Copy Markdown

Pull request dashboard status

Status last refreshed: 2026-07-21 01:14:27 UTC.

  • Waiting on: Author
  • Next step: Move out of draft to request review.

This automated status or its linked feedback items may be incorrect. If something looks wrong, report it with the result you expected.

@singhvibhanshu

Copy link
Copy Markdown
Member Author

/rerun

@singhvibhanshu

Copy link
Copy Markdown
Member Author

/rerun

Comment thread receiver/sqlserverreceiver/factory.go Outdated
if p == nil {
return nil
}
p.closeOnce.Do(func() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: If close() is called before getDB() has ever been invoked (as happens on all errors.Join(err, provider.close()) error paths), closeOnce fires while p.db == nil. If anything later manages to call getDB(), openOnce will still run and open a pool that close() will now refuse to touch (its once has already fired), silently leaking the *sql.DB. Consider guarding: only call p.closeOnce.Do when p.db != nil, or gate getDB() with a closed flag so it returns an error after close(). Today the call graph doesn’t trigger this (controller-failure paths return before scrapers start), but the invariant is fragile enough to warrant defensive handling.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Replaced the dual-sync.Once with a mutex + closed flag so getDB() refuses to open after close().
PTAL 🙏🏻

@singhvibhanshu

Copy link
Copy Markdown
Member Author

@splunk-shanu,
I marking this PR as a draft but feel free to give it a look.

@singhvibhanshu
singhvibhanshu marked this pull request as draft July 16, 2026 17:03
@singhvibhanshu

Copy link
Copy Markdown
Member Author

/rerun

@singhvibhanshu

Copy link
Copy Markdown
Member Author

@splunk-shanu, I marking this PR as a draft but feel free to give it a look.

cc: @crobert-1, @sincejune, @XSAM, @ebrdarSplunk, @sv-splunk, @akshays-19

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SQL Server Receiver: Implement shared connection pooling across scrapers

2 participants