feat(2meet-data-optimizer): sample drift daily and record the result
- TMDO_Drift_Check::cron_tick() runs on the existing wpdo_daily_health_check event (no new schedule to add or clear): every entity type whose flat tables are written (dual_write or higher) is checked on 500 random entities per group, and the outcome replaces the recorded status, so a group found drifting leaves the router that day. - Verify: DriftCheckTest cron cases (RED: method / hook missing); dev36 with all four entities in dual_write: one tick over 22 groups in 10 s, 0 drift, status option restored. - PR: PR-073
This commit is contained in:
@@ -40,6 +40,11 @@ final class TMDO_Drift_Check {
|
||||
*/
|
||||
public const OPTION = 'wpdo_drift_status';
|
||||
|
||||
/**
|
||||
* Entities per group sampled by the daily check.
|
||||
*/
|
||||
public const CRON_SAMPLE = 500;
|
||||
|
||||
/**
|
||||
* MySQL regex for a plain decimal number, used to skip rows that obviously match.
|
||||
* Exact matches compare BINARY: meta and flat tables may differ in collation,
|
||||
@@ -97,6 +102,24 @@ final class TMDO_Drift_Check {
|
||||
return $report;
|
||||
}
|
||||
|
||||
/**
|
||||
* Daily check (wpdo_daily_health_check): sample every entity type whose
|
||||
* flat tables are written (mode dual_write or higher). The outcome replaces
|
||||
* the recorded status, so a group found drifting leaves the router at once.
|
||||
*/
|
||||
public static function cron_tick(): void {
|
||||
foreach ( TMDO_Entity_Registry::VALID_ENTITY_TYPES as $entity_type ) {
|
||||
if ( ! TMDO_Mode_Manager::writes_to_flat( $entity_type ) ) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
self::run( $entity_type, '', self::CRON_SAMPLE );
|
||||
} catch ( InvalidArgumentException $e ) {
|
||||
continue; // No adapter for this entity type on this site.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuild drifted flat rows from native meta, then check again.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user