عرض عملي: مهمة ليلية تعمل مرة واحدة عبر ثلاث نسخ
في هذا الدرس 3 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
run reconciliation exactly once and fence its writes. Prepares MID-032-LAB1.
تفاصيل المخطط المبدئي
خطوة بخطوة
- Scale
ordersto three replicas; the@Scheduledreconciliation job runs three times. - Add ShedLock with a JDBC lock provider (verify library and version before recording) and annotate with
@SchedulerLock(name = "recon", lockAtMostFor = "10m"). - Run again: one replica executes, others skip.
- Planned mistake: set
lockAtMostForshorter than the job. A second replica starts while the first still runs. Fix: size it above the worst-case runtime and fence the writes. - Add a lock-generation number as a fencing token on the state table.
- Pause the lock holder with
docker pause, let the lease expire, let another run, unpause, and show the stale writes are rejected.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.