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

Database: add primary key to device_graphs #11323

Closed
wants to merge 1 commit into from

Conversation

rkojedzinszky
Copy link
Contributor

Percona Xtradb refused to INSERT IGNORE into a table
without a primary key.

DO NOT DELETE THIS TEXT

Please note

Please read this information carefully. You can run ./scripts/pre-commit.php 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.

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.

*/
public function up()
{
DB::table('device_graphs')->delete();
Copy link
Member

Choose a reason for hiding this comment

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

This can't be right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, that table might contain duplicates, as no constraint prevented that. Thus, clear the table, then add the primary key. Also, poller modules will fill the table upon next run. Am I right?

Copy link
Member

Choose a reason for hiding this comment

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

@rkojedzinszky you can run through and delete duplicates first.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately, on a table without a primary key, you cannot delete just duplicates. You cannot identify them :)

Copy link
Member

Choose a reason for hiding this comment

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

Add a new column with a primary key first then.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately, I am not a php developer, and perhaps, a bigger refactor would be needed here, which I cannot handle. The original problem involves a table without primary key and inserting into it with insert ignore. This breaks librenms on percona xtradb. Perhaps, the real solution is somewhere else.

@murrant
Copy link
Member

murrant commented Mar 22, 2020

IMO, delete duplicates, add primary key id, add unique index on device_id and graph.

Percona Xtradb refused to INSERT IGNORE into a table
without a primary key.
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.

None yet

3 participants