Skip to content

Conversation

@0xgouda
Copy link
Collaborator

@0xgouda 0xgouda commented Nov 17, 2025

  • Create new PL/pgSQL functions containing the maintenance logic.
    • admin.try_get_maintenance_lock().
    • admin.update_listing_table(metric_table_name text).
    • admin.remove_dropped_tables_listing(existing_metrics text[]).
  • Call these functions from the Golang maintenance routine.

@0xgouda 0xgouda requested a review from pashagolub November 17, 2025 03:50
@0xgouda 0xgouda added enhancement New feature or request refactoring Something done as it should've been done from the start sinks Where and how to store monitored data labels Nov 17, 2025
@pashagolub pashagolub force-pushed the make-maintenance-in-plpgsql branch from 5c6510c to c245c16 Compare November 17, 2025 16:39
@coveralls
Copy link

coveralls commented Nov 17, 2025

Pull Request Test Coverage Report for Build 19437140385

Details

  • 18 of 22 (81.82%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.09%) to 73.597%

Changes Missing Coverage Covered Lines Changed/Added Lines %
internal/sinks/postgres.go 18 22 81.82%
Totals Coverage Status
Change from base Build 19436814112: -0.09%
Covered Lines: 3646
Relevant Lines: 4954

💛 - Coveralls

if err := pgw.sinkDb.QueryRow(pgw.ctx, sqlGetAdvisoryLock).Scan(&lock); err != nil {
logger.Error("Getting admin.all_distinct_dbname_metrics maintainer advisory lock failed:", err)
logger.Infof("Trying to get maintenance advisory lock...") // to only have one "maintainer" in case of a "push" setup, as can get costly
if err := pgw.sinkDb.QueryRow(pgw.ctx, "SELECT admin.try_get_maintenance_lock();").Scan(&lock); err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure it's a great improvement! :-D

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's not, but I think of it in terms of abstracting the maintenance logic from the Go code.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Got it. I will get back to this later. I want to experiment locally. Need to produce some loads first.

@pashagolub pashagolub self-assigned this Nov 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request refactoring Something done as it should've been done from the start sinks Where and how to store monitored data

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants