Skip to content

Commit a6b651b

Browse files
committed
docs(sharding): clarify rollback and update docs
- Explain rollback usage in sharding context - Refresh related component documentation
1 parent c3b98ad commit a6b651b

File tree

5 files changed

+22
-20
lines changed

5 files changed

+22
-20
lines changed

doc/sharding/07-error-handling.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ public function shard(Queue $queue, int $shardCount, int $replicationFactor = 2)
1818
$operationGroup = "shard_create_{$this->name}_" . uniqid();
1919

2020
try {
21-
// All operations in this group
22-
$queue->addWithRollback($node, $createSql, $rollbackSql, $operationGroup);
21+
// All operations in this group (rollback required)
22+
$queue->add($node, $createSql, $rollbackSql, $operationGroup);
2323
// ... more operations
2424

2525
return $result;

doc/sharding/08-testing.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,12 +364,14 @@ private function createTestableQueue(): TestableQueue {
364364
parent::__construct();
365365
}
366366

367-
public function add(string $nodeId, string $query): int {
367+
public function add(string $nodeId, string $query, string $rollbackQuery, ?string $operationGroup = null): int {
368368
$queueId = $this->nextQueueId++;
369369
$command = [
370370
'id' => $queueId,
371371
'node' => $nodeId,
372372
'query' => $query,
373+
'rollback_query' => $rollbackQuery,
374+
'operation_group' => $operationGroup ?? '',
373375
'wait_for_id' => end($this->waitForIds) ?: null,
374376
];
375377
$this->capturedCommands[] = $command;

doc/sharding/09-production.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -278,17 +278,17 @@ The sharding system now includes automatic rollback capabilities for all operati
278278
class RollbackMonitoring {
279279
public function getRollbackMetrics(): array {
280280
$queueTable = 'system.sharding_queue';
281-
281+
282282
// Count rollback operations
283283
$result = $this->client->sendRequest("
284-
SELECT
284+
SELECT
285285
COUNT(*) as total_operations,
286286
SUM(CASE WHEN rollback_query != '' THEN 1 ELSE 0 END) as rollback_enabled,
287287
COUNT(DISTINCT operation_group) as operation_groups
288288
FROM {$queueTable}
289289
WHERE created_at > " . ((time() - 86400) * 1000) // Last 24 hours
290290
);
291-
291+
292292
return [
293293
'rollback_coverage' => $rollback_enabled / $total_operations * 100,
294294
'operation_groups_24h' => $operation_groups,
@@ -307,18 +307,18 @@ Configure automatic health monitoring and recovery:
307307
class HealthMonitoringCron {
308308
public function run(): void {
309309
$monitor = new HealthMonitor($this->client, $this->cluster);
310-
310+
311311
// Perform health check
312312
$health = $monitor->performHealthCheck();
313-
313+
314314
// Log health status
315315
$this->logHealthStatus($health);
316-
316+
317317
// Auto-recovery if needed
318318
if ($health['overall_status'] !== 'healthy') {
319319
$recovery = $monitor->performAutoRecovery();
320320
$this->logRecoveryActions($recovery);
321-
321+
322322
// Alert if recovery failed
323323
if (!empty($recovery['failed_recoveries'])) {
324324
$this->sendAlert('Recovery failed', $recovery['failed_recoveries']);
@@ -340,13 +340,13 @@ class CleanupSchedule {
340340
$cleanup = new CleanupManager($this->client, $this->cluster);
341341
$cleanup->cleanupOrphanedTemporaryClusters();
342342
}
343-
343+
344344
// Run daily
345345
public function dailyCleanup(): void {
346346
$cleanup = new CleanupManager($this->client, $this->cluster);
347347
$cleanup->cleanupFailedOperationGroups();
348348
}
349-
349+
350350
// Run weekly
351351
public function weeklyCleanup(): void {
352352
$cleanup = new CleanupManager($this->client, $this->cluster);
@@ -365,32 +365,32 @@ class RebalancingController {
365365
// Check before maintenance
366366
public function prepareForMaintenance(): void {
367367
$tables = $this->getShardedTables();
368-
368+
369369
foreach ($tables as $tableName) {
370370
$table = new Table($this->client, $this->cluster, $tableName, '', '');
371-
371+
372372
// Stop any running rebalancing
373373
$result = $table->stopRebalancing(true); // Graceful stop
374-
374+
375375
if ($result['status'] === 'stop_requested') {
376376
// Wait for graceful stop
377377
$this->waitForStop($tableName);
378378
}
379379
}
380380
}
381-
381+
382382
// Emergency stop
383383
public function emergencyStop(string $tableName): void {
384384
$table = new Table($this->client, $this->cluster, $tableName, '', '');
385-
385+
386386
// Immediate stop with rollback
387387
$result = $table->stopRebalancing(false);
388-
388+
389389
if ($result['rollback_executed']) {
390390
$this->logEmergencyStop($tableName, $result);
391391
}
392392
}
393-
393+
394394
// Monitor progress
395395
public function monitorProgress(string $tableName): array {
396396
$table = new Table($this->client, $this->cluster, $tableName, '', '');

src/Config/mysql_vars.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,4 +654,4 @@
654654
"warning_count": 0,
655655
"windowing_use_high_precision": 1,
656656
"xa_detach_on_prepare": 1
657-
}
657+
}

src/Plugin/EmulateElastic/FieldCapsHandler.php

100755100644
File mode changed.

0 commit comments

Comments
 (0)