Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated bill_data table, alter indexes and add new column #15751

Merged
merged 29 commits into from Jan 22, 2024

Conversation

laf
Copy link
Member

@laf laf commented Jan 15, 2024

3rd times a charm

This is to resolve an issue where distributed bill polling will try and insert two entries for the same bill_id and timestamp causing a duplicate clash and one entry being dropped meaning bills are missing data.

Also added a new unique id to the table to provide better support for Galera clusters.

Two db migrations because trying to drop the old primary index and create the new auto incrementing column with a primary index in one migration clashes:

SQLSTATE[42000]: Syntax error or access violation: 1068 Multiple primary key defined (Connection: mysql, SQL: alter table bill_dataaddid bigint unsigned not null auto_increment primary key)

Separating them out resolves this.

This will cause locking on installs with a large number of bills.

MariaDB [librenms]> ALTER TABLE bill_data ADD COLUMN bill_data_id int unsigned AUTO_INCREMENT PRIMARY KEY FIRST;
Query OK, 0 rows affected (9 min 13.948 sec)        
Records: 0  Duplicates: 0  Warnings: 0

This is on 65M+ records in that table on a 3GB VM with 1 vCPU. Performance should be better on larger sized MySQL installs.

DO NOT DELETE THE UNDERLYING TEXT

Please note

Please read this information carefully. You can run ./lnms dev:check to check your code before submitting.

  • Have you followed our code guidelines?
  • If my Pull Request does some changes/fixes/enhancements in the WebUI, I have inserted a screenshot of it.
  • If my Pull Request makes discovery/polling/yaml changes, I have added/updated test data.

Testers

If you would like to test this pull request then please run: ./scripts/github-apply <pr_id>, i.e ./scripts/github-apply 5926
After you are done testing, you can remove the changes with ./scripts/github-remove. If there are schema changes, you can ask on discord how to revert.

@laf laf closed this Jan 15, 2024
@laf laf reopened this Jan 15, 2024
Copy link
Member

@murrant murrant left a comment

Choose a reason for hiding this comment

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

Fingers crossed

@murrant murrant merged commit 7325995 into librenms:master Jan 22, 2024
8 checks passed
@laf laf deleted the bill-data-db-2 branch January 22, 2024 21:20
@librenms-bot
Copy link

This pull request has been mentioned on LibreNMS Community. There might be relevant details there:

https://community.librenms.org/t/24-2-0-changelog/23721/1

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

Successfully merging this pull request may close these issues.

None yet

3 participants