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

schemaCachingDuration is not working #4561

Closed
wants to merge 1 commit into from

Conversation

albertborsos
Copy link
Contributor

@albertborsos albertborsos commented Aug 3, 2024

I realized the CDbConnection.schemaCachingDuration property has no effect.
We use this config only in staging and production, but after the deploy we get exceptions for missing attributes.

That is why I wrote this test to prove that schemaCachingDuration settings does not work.

You can run this test from the tests folder:

php ../vendor/bin/phpunit framework/db/CDbConnectionTest.php --filter testSchemaCachingDuration

Q A
Is bugfix? ✔️
New feature?
Breaks BC?
Tests pass?
Fixed issues

Copy link
Member

@Arhell Arhell left a comment

Choose a reason for hiding this comment

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

@albertborsos
Copy link
Contributor Author

albertborsos commented Aug 4, 2024

I was not fully accurate in the description. schemaCachingDuration has effect, because it caches the schema, but after the duration it does not invalidate the cached schema.

@marcovtwout
Copy link
Member

If I read the code correctly, the duration is used between requests. But within one request table data is always cached (in https://github.com/yiisoft/yii/blob/master/framework/db/schema/CDbSchema.php#L34 which is always checked first in https://github.com/yiisoft/yii/blob/master/framework/db/schema/CDbSchema.php#L74). Can you confirm this is the case for you?

If you need to force new schema data within one request, you can call schema->refresh() as you've probably already seen.

@albertborsos
Copy link
Contributor Author

thanks @marcovtwout , we have issues between requests. So you are right, my test cases are not correct. I will update it soon.

Since then I realized we use a custom cache which stores data in couchbase (correctly with expiration), but I have to investigate it more deeply.

For now, I close this ticket, since there is a lack of chance there is this bug in the framework for 10+ years.

Thanks.

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.

3 participants