@@ -301,9 +301,15 @@ func generatedClientPoolEntries(config *Config) []ProviderEntry {
301301//
302302// The pipeline must run in prewarmed mode afterwards (Services.SetPrewarmed),
303303// so the periodic reliability-score recompute does not overwrite these rows;
304- // it keeps refreshing the location reliabilities (so churn still gates
305- // selection) and re-exporting the redis samples.
306- func provisionPrewarm (ctx context.Context , lookback time.Duration , entries []ProviderEntry ) error {
304+ // it refreshes connected/location state, restores provider-scoped fixture
305+ // performance after mechanical transport replacement, and re-exports the
306+ // redis samples (so churn still gates selection).
307+ func provisionPrewarm (
308+ ctx context.Context ,
309+ lookback time.Duration ,
310+ entries []ProviderEntry ,
311+ services * Services ,
312+ ) error {
307313 reliabilities , err := matureProviderReliabilities (entries )
308314 if err != nil {
309315 return err
@@ -312,6 +318,7 @@ func provisionPrewarm(ctx context.Context, lookback time.Duration, entries []Pro
312318 if err != nil {
313319 return err
314320 }
321+ services .SetPrewarmed (performances )
315322
316323 // The prewarm is DB-heavy (a fleet-wide reliability rebuild plus a score
317324 // upsert). With a very large fleet connected, postgres can be transiently
@@ -425,8 +432,9 @@ func prewarmOnce(
425432
426433 // build network_client_location_reliability from the currently connected,
427434 // latency/speed-tested providers
428- writeMatureProviderPerformances (ctx , performances )
435+ writeMatureProviderConnectionPerformances (ctx , performances )
429436 model .UpdateClientLocationReliabilities (ctx , now .Add (- lookback ), now )
437+ writeMatureProviderPerformanceSnapshot (ctx , performances )
430438 writeMatureReliabilityScores (ctx , now , lookback , reliabilities )
431439 return nil
432440}
@@ -435,9 +443,9 @@ func prewarmOnce(
435443// building the location-reliability snapshot. Completed tests belong to a
436444// specific platform transport, so relying on an earlier transport's tests made
437445// a newly active connection look untested and excluded it from matchmaking.
438- // Writing the connection tables, instead of only the derived snapshot, also
439- // makes later pipeline refreshes preserve the prewarmed evidence .
440- func writeMatureProviderPerformances (
446+ // The provider-scoped snapshot restoration below handles later transport
447+ // replacement and pipeline refreshes.
448+ func writeMatureProviderConnectionPerformances (
441449 ctx context.Context ,
442450 performances []matureProviderPerformance ,
443451) {
@@ -504,6 +512,50 @@ func writeMatureProviderPerformances(
504512 })
505513}
506514
515+ // Restores provider-scoped mature-market performance after a location refresh.
516+ // A fixture provider can replace its platform transport before the new
517+ // connection finishes tests; the derived snapshot would otherwise discard the
518+ // provider's established evidence and collapse the matchmaking pool.
519+ func writeMatureProviderPerformanceSnapshot (
520+ ctx context.Context ,
521+ performances []matureProviderPerformance ,
522+ ) {
523+ clientIds := make ([]server.Id , 0 , len (performances ))
524+ minRelativeLatencyMillisValues := make ([]int64 , 0 , len (performances ))
525+ maxBytesPerSecondValues := make ([]int64 , 0 , len (performances ))
526+ for _ , performance := range performances {
527+ clientIds = append (clientIds , performance .clientId )
528+ minRelativeLatencyMillisValues = append (minRelativeLatencyMillisValues , performance .minRelativeLatencyMillis )
529+ maxBytesPerSecondValues = append (maxBytesPerSecondValues , performance .maxBytesPerSecond )
530+ }
531+
532+ server .Db (ctx , func (conn server.PgConn ) {
533+ server .RaisePgResult (conn .Exec (
534+ ctx ,
535+ `
536+ WITH mature_performance AS (
537+ SELECT client_id, min_relative_latency_ms, max_bytes_per_second
538+ FROM unnest($1::uuid[], $2::bigint[], $3::bigint[])
539+ AS mature(client_id, min_relative_latency_ms, max_bytes_per_second)
540+ )
541+ UPDATE network_client_location_reliability
542+ SET
543+ min_relative_latency_ms = mature.min_relative_latency_ms::integer,
544+ max_bytes_per_second = mature.max_bytes_per_second,
545+ has_latency_test = true,
546+ has_speed_test = true
547+ FROM mature_performance mature
548+ WHERE
549+ network_client_location_reliability.client_id = mature.client_id AND
550+ network_client_location_reliability.connected = true
551+ ` ,
552+ clientIds ,
553+ minRelativeLatencyMillisValues ,
554+ maxBytesPerSecondValues ,
555+ ))
556+ })
557+ }
558+
507559// Writes the seeded mature reliability beside the real connected/location and
508560// latency/speed evidence. An inner join keeps disconnected providers out.
509561func writeMatureReliabilityScores (
0 commit comments