-
Notifications
You must be signed in to change notification settings - Fork 853
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
fix: allow disabling field metadata cache #1052
Conversation
How do we test this ? |
@davecramer Good question, I was unsure the extent of testing that is typical for modifying previously untested code paths in this project so was going to add a follow-up comment asking for input. I can certainly make a test that creates a table, reads from it, modifies the data type of a column, then reads from it again and ensures that the correct new type is returned when caching is disabled and the old "incorrect" value is returned when caching is enabled. Does that seem sufficient? It wouldn't be full coverage of the caching codepath but we would have a test that fails before the fix and passes after, and one that "passes" both before and after the fix. |
@znep we'd certainly like to make sure that the codepath has some testing and that this couldn't occur again due to some change in the future. Your proposed test sounds like a great start! |
As far as I read the code, a mere That is it makes sense to add @znep , any luck with pushing this forward? |
@znep ping ? |
Hi guys, I haven't had a chance to circle back to this yet but still plan to this week, I'll take a look at @vlsi 's suggestion. |
Clients accessing very dynamic schemas can have issues with the field metadata cache getting stale. This change allows configuring the databaseMetadataCacheFields property to 0 to disable the cache and avoid these issues where necessary. This behaviour was already documented, however did not actually work as the codepath assumed it could retrieve the fields from the cache.
07b4847
to
8726099
Compare
Codecov Report
@@ Coverage Diff @@
## master #1052 +/- ##
============================================
+ Coverage 69.14% 69.18% +0.04%
- Complexity 3790 3797 +7
============================================
Files 170 171 +1
Lines 15760 15765 +5
Branches 2578 2578
============================================
+ Hits 10897 10907 +10
+ Misses 3621 3618 -3
+ Partials 1242 1240 -2 |
@davecramer @vlsi None of the existing I verified the tests fail as I expect without my fix. |
@davecramer @vlsi ping, anything else I should add here? Thanks. |
@znep , it looks good, however I wonder if I think the end of What do you think? |
This is a minor optimization, previously the second call to fetchFieldMetaData would iterate through each field and see it was already set, set fieldInfoFetched to true and return.
@vlsi Good catch, thanks for looking. I agree it should be, this isn't a regression from my changes and is a pretty minor optimization (it doesn't actually refetch it from the cache or db, just iterates through all the fields and sees they are already set) but I pushed a fix. I'm not seeing a way to add test coverage for this without some fairly major structural changes. (build currently failing due to travis apt-get issues...) |
As a follow-up it might make sense to add metadata cache invalidation on |
Clients accessing very dynamic schemas can have issues with the
field metadata cache getting stale. This change allows configuring the
databaseMetadataCacheFields property to 0 to disable the cache and
avoid these issues where necessary. This behaviour was already
documented, however did not actually work as the codepath assumed
it could retrieve the fields from the cache.