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

feat: add a new implementation of schema with ttl #5462

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

shekhar-rudder
Copy link
Member

@shekhar-rudder shekhar-rudder commented Jan 29, 2025

Description

This PR introduces schema invalidation based on a configurable TTL. When a schema entry expires, it is refreshed from the warehouse and updated in storage.

Changes:

  • Added an expires_at column to the wh_schemas table.
  • Implemented a new schema version (schema_v2), gated by a feature flag.
  • In schema_v2:
    1. Entries in the table are marked with an expiration timestamp (now + TTL) upon insert/update.
    2. Reads first validate the schema’s expiration status—if valid, it is returned; otherwise, it is re-fetched from the warehouse.
  • Updated database read/write methods to handle the new column.
  • Modified the NewSchema function to accept whManager, allowing schema_v2 to reference the repository.
  • Adjusted method signatures in the Handler interface to accept a context and return an error, as most schema_v2 methods now interact with the database.
  • Extracted removeDeprecatedColumns and tableSchemaDiff from schemaV1 for reuse in schemaV2.

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

@shekhar-rudder shekhar-rudder force-pushed the war-177-schema-ttl branch 10 times, most recently from 6cc5479 to ef40a95 Compare January 31, 2025 08:54
@shekhar-rudder shekhar-rudder force-pushed the war-177-schema-ttl branch 3 times, most recently from 1110046 to f36f3e3 Compare January 31, 2025 16:37
Copy link

codecov bot commented Jan 31, 2025

Codecov Report

Attention: Patch coverage is 71.58470% with 52 lines in your changes missing coverage. Please review.

Project coverage is 74.85%. Comparing base (66139a2) to head (f36f3e3).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
warehouse/schema/schema_v2.go 71.65% 25 Missing and 11 partials ⚠️
warehouse/router/state_export_data.go 23.80% 11 Missing and 5 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5462      +/-   ##
==========================================
+ Coverage   74.79%   74.85%   +0.06%     
==========================================
  Files         440      441       +1     
  Lines       61490    61662     +172     
==========================================
+ Hits        45991    46157     +166     
+ Misses      12962    12957       -5     
- Partials     2537     2548      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

1 participant