Skip to content

[DCP Ingestion - Stale Reads] Enable Stale Reads in CDC Web server which runs mixer#31

Merged
gmechali merged 5 commits intodatacommonsorg:mainfrom
gmechali:stalereads
Apr 20, 2026
Merged

[DCP Ingestion - Stale Reads] Enable Stale Reads in CDC Web server which runs mixer#31
gmechali merged 5 commits intodatacommonsorg:mainfrom
gmechali:stalereads

Conversation

@gmechali
Copy link
Copy Markdown
Contributor

@gmechali gmechali commented Apr 16, 2026

This is a very small change to the Terraform script to add the USE_STALE_READS environment variable to the Cloud Run Service running the CDC image. This server startups mixer, and will pass in the right feature flags based on the USE_STALE_READS env variable.

See the complementary change in datacommonsorg/website#6215

Currently deployed in https://pantheon.corp.google.com/run/detail/us-central1/gabe-test-datacommons-web-service/observability/logs?e=13803378&inv=1&invt=Ab1zPA&mods=-monitoring_api_staging&project=datcom-website-dev

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds a hardcoded USE_STALE_READS environment variable to the shared configuration for Cloud Run services. Feedback indicates that applying this globally poses a data consistency risk for ingestion jobs and limits maintainability; it is recommended to move this setting to the web service configuration and make it configurable via a variable.

Comment thread infra/dcp/modules/cdc/locals.tf Outdated
Comment on lines 75 to 78
{
name = "USE_STALE_READS"
value = var.use_spanner ? "true" : "false"
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

Enabling USE_STALE_READS in the shared environment variables list (cloud_run_shared_env_variables) is problematic for two reasons:

  1. Data Consistency Risk: This setting is applied to both the web service and the dc_data_job (data management/ingestion). Stale reads can lead to data corruption or inconsistent states if the ingestion job performs read-modify-write operations or relies on reading the most recent updates. Data management tasks typically require strong consistency.
  2. Maintainability: Hardcoding the value to "true" prevents users from disabling this feature (e.g., for debugging or specific consistency requirements) without modifying the module code.

It is recommended to move this environment variable to the web service configuration only (in main.tf) and make it configurable via a variable in variables.tf.

@gmechali gmechali requested a review from dwnoble April 17, 2026 16:49
@gmechali
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the USE_STALE_READS environment variable to the Cloud Run service, with its value determined by the Spanner usage flag. Feedback suggests centralizing this configuration in locals.tf to maintain consistency with the module's existing pattern for environment variables.

Comment thread infra/dcp/modules/cdc/main.tf Outdated
@gmechali gmechali requested a review from n-h-diaz April 20, 2026 19:36
@gmechali gmechali added this pull request to the merge queue Apr 20, 2026
Merged via the queue into datacommonsorg:main with commit d4a1f29 Apr 20, 2026
3 checks passed
@gmechali gmechali deleted the stalereads branch April 21, 2026 15:28
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.

2 participants