Repository navigation
SpannerToSourceDbLargeBacklogLT: fix assertion mechanism - #4514
Conversation
…ad of success_record_count success_record_count can permanently fall short of the real count (for example, increments are lost when workers are removed), which made the test time out even though all rows reached MySQL. Poll the row count of the shadow table in the metadata database instead: each shadow row is written in the same Spanner transaction as its MySQL write and commits after it. success_record_count is still logged for information, and the shadow COUNT(*) duration is logged.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4514 +/- ##
============================================
+ Coverage 56.87% 63.60% +6.73%
+ Complexity 8087 3088 -4999
============================================
Files 1164 582 -582
Lines 74114 34524 -39590
Branches 8735 3961 -4774
============================================
- Hits 42150 21960 -20190
+ Misses 29164 11450 -17714
+ Partials 2800 1114 -1686
🚀 New features to boost your workflow:
|
…, drop success_record_count logging Add SpannerToSourceDbOptions.DEFAULT_SHADOW_TABLE_PREFIX and use it for both the option default and the LT's shadow table name, so the LT keeps polling the right table if the default prefix changes. Stop logging success_record_count, which the LT no longer uses.
|
✅ Codelab Update Reminder Assured Please follow the step-by-step instructions in go/update-migrations-codelabs to update the codelabs with your changes. |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses intermittent failures in the 'SpannerToSourceDbLargeBacklogLT' load test. The previous reliance on Dataflow's 'success_record_count' metric proved unreliable due to lost counter increments during worker downscaling. By switching to a direct 'SELECT COUNT(*)' on the shadow table, the test now accurately tracks replication completion, significantly improving the stability and reliability of the long-running load test. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request refactors the SpannerToSourceDbLargeBacklogLT load test to poll the row count of the shadow table in the metadata database instead of relying on the unreliable success_record_count Dataflow metric. It also defines a default shadow table prefix constant in SpannerToSourceDbOptions. The feedback suggests changing the exact equality check (==) for the shadow table row count to a greater-than-or-equal-to check (>=) to prevent the test from failing or timing out due to duplicate writes or retries.
…/v2/templates/SpannerToSourceDbLargeBacklogLT.java Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
SpannerToSourceDbLargeBacklogLTnow waits for the shadow table in the metadata database to reach the expected row count, instead of waiting for the Dataflow countersuccess_record_count. The counter can stay short forever even when every row has reached MySQL, which made the test time out.Problem
About 5 of the last 12 runs failed the same way. The reverse replication job processed the whole 1B-row backlog, but
success_record_countstopped a little short of 1e9 (318, 134,018 and 56 rows short on 10-06, 10-09 and 10-20) and never moved again. The test only runs the MySQL row count after the counter reaches 1e9, so it waited until the 600 min timeout and failed without ever checking MySQL. A longer timeout would not help: the counter stayed flat for up to 2.5 hours before the timeout in past runs.Root cause
success_record_countis not an exact count of applied rows. For each record, the writer commits the MySQL write and the shadow table row in one Spanner transaction, and only then increments the counter. Dataflow reports counter increments from each worker periodically. If a worker is removed after the transaction commits but before its increments are reported, those increments are lost. The record is never counted again: on any retry the writer sees that its shadow row is already applied and skips it without counting.At the end of the backlog, the Dataflow autoscaler removes about 199 of the 200 workers in one step. In every failed run we looked at, that downscale happened before the counter reached 1e9, and the counter froze right after it. In the passing runs, the downscale happened after the counter reached 1e9.
Fix
SELECT COUNT(*)on the shadow tablerev_shadow_MigrationLoadTestevery 15 minutes and pass when it equalsexpectedSpannerCount. This is a valid stand-in for "all rows are in MySQL" because each shadow row is written in the same transaction as its MySQL write and commits after it, there is one shadow row per primary key, the table starts empty, and this test only inserts rows and has no custom filtering.SpannerToSourceDbOptions.DEFAULT_SHADOW_TABLE_PREFIXand use it for both the option default and the test's shadow table name, so the test keeps polling the right table if the default prefix changes.COUNT(*)takes. This is temporary, to confirm the query cost on another run, and can be removed after that.metricThresholdproperty.Evidence
I tracked the failure that happened this week (on 3rd nov) with a long running agent task - this run showed the counter stall and failed after timing out, but the shadow table count during this stall had reached 1 billion. This is proof that there's no data issue, its a counter mismatch and we need to stop asserting on it
The 11-02 run is the clearest case: with the old gate it would have timed out, while the data was complete.
Shadow
COUNT(*)cost on 11-02 (metadata instance at 20 nodes during replication, 30 polls):The only failed poll was the first one, about 2.5 minutes after the reverse job started, most likely because the template had not yet created the shadow table. The test retried 15 minutes later as intended.
Testing
-DspecPath): passed, 30,480 s, teardown cleaned up all resources.CODELAB_BUG=b/12345678 (dummy)