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

Try setting wsrep_sync_wait for mysql connections #711

Merged
merged 10 commits into from Apr 5, 2024

Conversation

yhabteab
Copy link
Member

@yhabteab yhabteab commented Mar 19, 2024

This PR is an alternative version of #665 and utilises what is described in #665 (comment).

Using this PR avoids the need for custom driver registration and also eliminates the need for any other custom connectors/drivers that aren't of type driver.RetryConnector. This PR also adds an option to driver.RetryConnector to post initialise a connection after Connector#Connect().

closes #665

pkg/driver/driver.go Outdated Show resolved Hide resolved
pkg/driver/driver.go Outdated Show resolved Hide resolved
pkg/config/database.go Outdated Show resolved Hide resolved
@julianbrost julianbrost added this to the 1.1.2 milestone Mar 20, 2024
@yhabteab yhabteab force-pushed the drop-custom-driver-registry branch from 534fe0f to bb74479 Compare March 20, 2024 09:20
@yhabteab yhabteab force-pushed the drop-custom-driver-registry branch from bb74479 to 8ec605d Compare March 20, 2024 09:59
Copy link
Contributor

@julianbrost julianbrost left a comment

Choose a reason for hiding this comment

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

Before I go too deep into implementation details: @lippserd Do you see any issue in removing registering the named drivers in the sql package?

Apart from that, just one comment of something I found strange so far.

pkg/driver/driver.go Outdated Show resolved Hide resolved
@yhabteab yhabteab force-pushed the drop-custom-driver-registry branch 2 times, most recently from f80bdce to e9d187a Compare March 22, 2024 10:44
@yhabteab yhabteab requested review from julianbrost and lippserd and removed request for lippserd March 22, 2024 10:46
@lippserd
Copy link
Member

Before I go too deep into implementation details: @lippserd Do you see any issue in removing registering the named drivers in the sql package?

Nope, removing them is fine.

pkg/driver/driver.go Outdated Show resolved Hide resolved
pkg/config/database.go Outdated Show resolved Hide resolved
pkg/config/database.go Outdated Show resolved Hide resolved
@yhabteab yhabteab force-pushed the drop-custom-driver-registry branch 3 times, most recently from 089bef9 to 7b3f0ed Compare March 25, 2024 09:54
@yhabteab yhabteab requested a review from lippserd March 25, 2024 09:54
@yhabteab yhabteab force-pushed the drop-custom-driver-registry branch from 7b3f0ed to 12909f9 Compare March 25, 2024 12:01
@yhabteab yhabteab requested a review from Al2Klimov March 25, 2024 14:35
Copy link
Member

@Al2Klimov Al2Klimov left a comment

Choose a reason for hiding this comment

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

Why did you drop my unit tests during cherry pick?

pkg/icingadb/driver.go Outdated Show resolved Hide resolved
@yhabteab
Copy link
Member Author

Why did you drop my unit tests during cherry pick?

What does exactly cover your unit tests? It's somewhat exaggerated just to test error cases that are ultimately triggered by the underlying driver, which does not lie within the responsibility of Icinga DB.

pkg/config/database.go Outdated Show resolved Hide resolved
pkg/icingadb/driver.go Outdated Show resolved Hide resolved
pkg/config/database.go Outdated Show resolved Hide resolved
pkg/icingadb/db.go Outdated Show resolved Hide resolved
pkg/icingadb/driver.go Outdated Show resolved Hide resolved
config.example.yml Outdated Show resolved Hide resolved
doc/03-Configuration.md Outdated Show resolved Hide resolved
julianbrost
julianbrost previously approved these changes Mar 27, 2024
@Al2Klimov Al2Klimov removed their request for review March 28, 2024 08:45
@yhabteab
Copy link
Member Author

I just have rebased this and resolved some conflicts!

@Al2Klimov
Copy link
Member

Why did you drop my unit tests during cherry pick?

What does exactly cover your unit tests? It's somewhat exaggerated just to test error cases that are ultimately triggered by the underlying driver, which does not lie within the responsibility of Icinga DB.

It is our responsibility to swallow the correct error.

@julianbrost
Copy link
Contributor

Why did you drop my unit tests during cherry pick?

What does exactly cover your unit tests? It's somewhat exaggerated just to test error cases that are ultimately triggered by the underlying driver, which does not lie within the responsibility of Icinga DB.

It is our responsibility to swallow the correct error.

You're probably referring to this test file from #665: https://github.com/Icinga/icingadb/blob/error-1452-foreign-key-577/pkg/driver/mysql_test.go

To be honest, I haven't looked at it in detail and it's not immediately obvious to me what this actually tests. So please explain them.

The current implementation isn't really ideal for testability. Maybe we could improve that by replacing setGaleraOpts(ctx, conn, wsrepSyncWait) with a more generic setSessionVariableIfExists(ctx, conn, variable, value) function that could then be tested against an actual database server in tests/sql/ with other variables. Like setting a random variable name to test that the error is ignored, setting a variable present on all MySQL/MariaDB versions to an invalid value to test the other error handling, etc.

@julianbrost
Copy link
Contributor

that could then be tested against an actual database server in tests/sql/

When writing this, I missed that this would add dependencies between icingadb/go.mod and icingadb/tests/go.mod that we want to avoid as the integration tests are supposed to test the functionality of a compiled Icinga DB binary and therefore not import its code.

As we plan to move that database code to icinga-go-library anyways, I'd rather take the opportunity there to add proper tests for more of the database code. @yhabteab already started a PR and I wrote a comment where I explained a bit how I imagine this: Icinga/icinga-go-library#10 (review)

The tests proposed in#665 seem to mainly test that one error handling condition is there with quite a bit of complexity in the test cases that seems unnecessary for what it's supposed to test. Restructuring the tests within this project when the corresponding implementation is supposed to be moved to another project soon anyways, feels like unnecessary work, so I'd actually postpone the proper automatic testing of this function until it has reached its new home. Apart from that, the existing integration tests already cover that this PR isn't fundamentally breaking anything and automatically testing that Icinga DB works with a Galera cluster as part of this PR is out of scope in any way.

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

5 participants