You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(sharding): add automatic rollback, health monitoring, and cleanup
- Introduce atomic operation groups with rollback commands
- Add rollback execution with error handling and schema migration
- Implement rebalancing controls: stop, pause, resume, and progress tracking
- Add HealthMonitor for issue detection and automatic recovery
- Provide CleanupManager for orphaned resources and stale states
- Extend queue schema and APIs to support rollback metadata
- Update documentation with usage examples and migration steps
### 4. State Class (`src/Plugin/Sharding/State.php`)
@@ -251,3 +265,147 @@ class TestableQueue {
251
265
-**Integration Testing**: Test with real dependencies where possible
252
266
253
267
This component architecture provides a robust, scalable foundation for distributed table sharding with comprehensive testing coverage and production-ready reliability.
268
+
269
+
## New Components (Rollback & Recovery System)
270
+
271
+
### 7. RollbackCommandGenerator Class (`src/Plugin/Sharding/RollbackCommandGenerator.php`)
272
+
273
+
Generates reverse SQL commands for rollback operations.
// Or manual intervention based on recommendations
362
+
foreach ($health['recommendations'] as $recommendation) {
363
+
echo $recommendation;
364
+
}
365
+
}
366
+
```
367
+
368
+
## Component Interaction Flows
369
+
370
+
### Rollback Flow
371
+
372
+
```
373
+
Table.shard()
374
+
├── Creates operation_group
375
+
├── Queue.addWithRollback() [multiple times]
376
+
├── On failure:
377
+
│ └── Queue.rollbackOperationGroup()
378
+
│ ├── getRollbackCommands()
379
+
│ └── executeRollbackSequence()
380
+
└── On success: Complete
381
+
```
382
+
383
+
### Health Monitoring Flow
384
+
385
+
```
386
+
HealthMonitor.performHealthCheck()
387
+
├── checkStuckOperations()
388
+
├── checkFailedOperations()
389
+
├── checkOrphanedResources()
390
+
├── checkQueueHealth()
391
+
└── generateRecommendations()
392
+
└── performAutoRecovery() [if needed]
393
+
├── recoverStuckOperation()
394
+
├── recoverFailedOperation()
395
+
└── CleanupManager.performFullCleanup()
396
+
```
397
+
398
+
### Rebalancing Control Flow
399
+
400
+
```
401
+
Table.rebalance()
402
+
├── Create operation_group
403
+
├── Check stop signal
404
+
├── Execute operations
405
+
│ └── Check stop signal between steps
406
+
├── On stop signal:
407
+
│ └── rollbackOperationGroup()
408
+
└── On completion: Clear operation_group
409
+
```
410
+
411
+
The enhanced component architecture now provides automatic rollback, health monitoring, and resource cleanup capabilities, making the sharding system more robust and production-ready.
0 commit comments