انتقل إلى المحتوى
أمين أبوزيد
درس مخطط لهMID-032-L04

رموز الحماية (Fencing Tokens)

  • الدرس 4 من 5
  • Mid-level
في هذا الدرس 4 موضوعات

هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.

نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.

في هذا الدرس

make stale holders harmless.

الموضوعات المخطط لها

  • A fencing token is a number that increases every time the lock is granted.
  • The holder sends the token with each write; the resource rejects writes with a token lower than one it has seen.
  • The check must be at the resource (database, storage), not only in the client.
  • In SQL: store last_token and add WHERE last_token <= :token to the update.
  • A version column or a monotonically increasing sequence can provide the token.
تفاصيل المخطط المبدئي

عرض عملي

sql
UPDATE recon_state SET last_token = :t, result = :r
WHERE id = 1 AND last_token <= :t;   -- 0 rows updated: you are stale, stop

اختبر فهمك

Where must the token be checked?

أظهر الإجابة

At the resource being written, not just in the client.

التطبيق

طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.

المختبر والتمارين الاختبار

تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.

اكتب للبحث في المستويات والمراحل والوحدات والدروس.