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

Add supported read isolation level to schema interface #22507

Merged

Conversation

caddoo
Copy link
Contributor

@caddoo caddoo commented Aug 15, 2024

Description:

TiDB doesn't support READ_UNCOMMITTED, I've added this variance to the schema.

To make sure it works, a test has been added to the LogAggregator making sure the supportsUncommitted doesn't switch to false but instead true

Review

@caddoo caddoo force-pushed the dev-18402-deactivate-transaction-level-checks-for-tidb branch 4 times, most recently from 0cafe50 to c2e60ac Compare August 16, 2024 04:59
@caddoo caddoo marked this pull request as ready for review August 16, 2024 05:59
@caddoo caddoo added not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. Needs Review PRs that need a code review labels Aug 16, 2024
@caddoo caddoo requested a review from a team August 16, 2024 06:01
@caddoo caddoo requested a review from sgiehl August 22, 2024 01:59
Copy link
Member

@sgiehl sgiehl left a comment

Choose a reason for hiding this comment

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

Some general things are missing around the deprecation of setUncommitted method:

The deprecation needs to be added to our changelog:

matomo/CHANGELOG.md

Lines 13 to 16 in d712ca6

## Deprecations
The methods `Db::isOptimizeInnoDBSupported` and `Db::optimizeTables` have been deprecated. Use `Db\Schema::getInstance()->isOptimizeInnoDBSupported` and `Db\Schema::getInstance()->optimizeTables` instead

And it would be good to add a test that ensures we don't forget to remove the method with Matomo 6:

$this->assertDeprecatedMethodIsRemovedInMatomo6('Piwik\Common', 'getRequestVar');
$this->assertDeprecatedMethodIsRemovedInMatomo6('Piwik\Plugins\Overlay\API', 'getExcludedQueryParameters');
$this->assertDeprecatedMethodIsRemovedInMatomo6('Piwik\Db', 'isOptimizeInnoDBSupported');
$this->assertDeprecatedMethodIsRemovedInMatomo6('Piwik\Db', 'optimizeTables');

return $this->setTransactionLevelForNonLockingReads();
}

public function setTransactionLevelForNonLockingReads(): bool
{
if ($this->db->supportsUncommitted === false) {
Copy link
Member

Choose a reason for hiding this comment

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

Guess it's discussable if the public db property should still be called supportsUncommitted, when it actually no longer holds that information.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree it's name wrong, on one side as well I'm not exactly sure why it's exposed as public in the first place.

Would you suggest making it private and make this class less leaky, along with a proper deprecation message?

Copy link
Member

Choose a reason for hiding this comment

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

I guess it's exposed public and set for the DB class, so the check is only performed once per DB connection. As the property shouldn't be used by any plugin I would say we can simply rename it, or make it private and introduce methods to handle that correctly.
We could even consider to handle everything through DB class, instead of using the TransactionLevel class directly.

@sgiehl sgiehl added this to the 5.2.0 milestone Aug 23, 2024
@caddoo
Copy link
Contributor Author

caddoo commented Aug 26, 2024

Some general things are missing around the deprecation of setUncommitted method:

The deprecation needs to be added to our changelog:

matomo/CHANGELOG.md

Lines 13 to 16 in d712ca6

## Deprecations
The methods `Db::isOptimizeInnoDBSupported` and `Db::optimizeTables` have been deprecated. Use `Db\Schema::getInstance()->isOptimizeInnoDBSupported` and `Db\Schema::getInstance()->optimizeTables` instead

And it would be good to add a test that ensures we don't forget to remove the method with Matomo 6:

$this->assertDeprecatedMethodIsRemovedInMatomo6('Piwik\Common', 'getRequestVar');
$this->assertDeprecatedMethodIsRemovedInMatomo6('Piwik\Plugins\Overlay\API', 'getExcludedQueryParameters');
$this->assertDeprecatedMethodIsRemovedInMatomo6('Piwik\Db', 'isOptimizeInnoDBSupported');
$this->assertDeprecatedMethodIsRemovedInMatomo6('Piwik\Db', 'optimizeTables');

Thanks for this, I've done these changes now.

@caddoo caddoo requested a review from sgiehl August 26, 2024 03:03
@sgiehl sgiehl force-pushed the dev-18402-deactivate-transaction-level-checks-for-tidb branch from 85d1751 to 787b46c Compare August 26, 2024 09:17
@caddoo caddoo merged commit f7b8630 into 5.x-dev Aug 28, 2024
25 checks passed
@caddoo caddoo deleted the dev-18402-deactivate-transaction-level-checks-for-tidb branch August 28, 2024 01:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants