الگوریتم های ترمیم تراکنش

الگوریتم های ترمیم تراکنش

برای تضمین جامعیت بانک اطلاعات یا Database و اعمال خواص یکپارچگی و پایائی تراکنش ها در صورت وقوع خرابی، از الگوریتم هایی استفاده می کنیم که عموما شامل دو مرحله زیر می باشند:

  1. مرحله اول : در حین عملکرد عادی سیستم، اطلاعاتی که برای انجام ترمیم ( پس از وقوع خرابی ) به آنها نیاز داریم در جایی ثبت شوند.
  2. مرحله دوم : پس از وقوع خرابی ( وقتی سیستم دوباره بالا می آید )، با استفاده از اطلاعات ثبت شده در مرحله قبل، خواص یکپارچگی و پایائی تراکنش ها اعمال گردند.

طبق خاصیت پایائی، اثرات تراکنشی که انجام شده باید دائمی و همیشگی گردد.

طبق خاصیت یکپارچگی، تراکنشی که نیمه کاره متوقف شده است نباید هیچ اثری روی بانک اطلاعات گذاشته باشد.

پس در مرحله دوم از الگوریتم ترمیم، هر تراکنشی که انجام Commit شده است را تکرار redo کرده ( دوباره اجرا می کنیم تا اثراتش روی بانک اطلاعات دائمی شود ) و هر تراکنشی که ساقط شده را خنثی یا Undo می کنیم. فرض می کنیم تراکنشها پی در پی هستند.

الگوریتم های ترمیم به دو رویکرد کلی تقسیم می شوند:

  • رویکرد کارنامه  یا Log Based
  • رویکرد رونوشت Shadow Paging

رویکرد کارنامه معایبی دارد که مهمترین آنها عبارتند از :

  1.  بزرگ شدن اندازه فایل کارنامه
  2. زمانگیر بودن جستجو در کارنامه
  3. احتمال تکرار مجدد تراکنش هایی که قبلا آنها را تکرار کرده ایم.
  4. افزایش هزینه به روز رسانی بانک اطلاعات به دلیل کار با رسانه.

برای رفع یا بهبود معایب روشهای ارایه شده که از جمله بهترین ها، استفاده از نقطه بازرسی یا checkpoint می باشد. در این روش، به طور متناوب در برهه های زمانی معینی از عملکرد عادی سیستم، کارهای انجام شده روی بانک اطلاعات ( تا آن زمان ) را قطعی و نهایی می کنیم که این لحظات نقاط بازرسی سیستم نام دارند.

در هر نقطه بازرسی مجموعه عملیات زیر به انجام می رسند:

  • رکوردهای کارنامه ( که در حین عملکرد عادی سیستم در بافر نوشته می شدند ) به حافظه پایدار منتقل می شوند.
  • داده های تغییر یافته در بافر به دیسک منتقل می گردند.
  • رکوردی به نام رکورد بازرسی با ساختار <checkpoint> ثبت می شود.

حال با وقوع خرابی، دیگر از آغاز کارنامه شروع به خواندن نمی کنیم، زیرا عملیات روی بانک اطلاعات تا آخرین نقطه بازرسی قطعی و نهایی شده اند. پس ترمیم فقط مربوط به بخشهایی از کارنامه می باشد که بعد از آخرین رکورد بازرسی هستند.

برای مدیریت فایل کارنامه از تکنیک برش کارنامه یا log truncation استفاده می کنیم تا بخش هایی از آغاز کارنامه که قبلا نهایی شده اند و دیگر نیازی به آنها نداریم را حذف نمائیم. به عبارت دیگر کارنامه دارای دو قمت فعال و بایگانی می باشد. قسمت فعال، حجم محدودی دارد و سرریز آن متناوبا به بایگانی منتقل می شود. سرریز قسمت بایگانی معمولا یادداشت هایی کهنه و بدردنخحور است که باید دور ریخته شود، ولی میتوان برای اطمینان بیشتر، آنها را در بایگانی های دست دوم و سوم نگهداری کرد. بایگانی ها را میتوان روی نوار مغناطیسی ذخیره نمود.

رویکرد رونوشت 

قبل از انجام تغییرات ( قبل از شروع به اجرای تراکنش ) یک کپی از صفحات مورد نیاز بانک اطلاعات تهیه می کنیم که آنرا نسخه سایه Shadow نامیده و در رسانه غیر فرار ذخیره می نمائیم. نسخه اصلی که تغییرات مورد نظر تراکنش فقط روی آن انجام می شود نسخه جاری یا Current نام دارد. چنانچه تراکنش به انجام رسید، این نسخه جاری را به عنوان بانک اطلاعات جدید تلقی می کنیم و نسخه سایه را از بین می بریم. اما اگر تراکنش نتوانست انجام شود، نسخه جاری را از بین برده و بانک اطلاعات معادل همان نسخه از سایه خواهد بود.

مزایای رویکرد رونوشت:

  1. سربار مربوط به نوشتن رکوردهای کارنامه ای را ندارد.
  2. انجام عملیات ترمیم بسیار ساده است.

معایب رویکرد رونوشت :

  1. برای پیاده سازی آن نیاز به کارنامه داریم.
  2. کپی کردن اطلاعات مربوطه از بانک بسیار پرهزینه است ( حتی با وجود بهینه سازی های انجام شده در این زمینه ).
  3. توسعه این روش برای حالتی که تراکنش ها بتوانند همروند اجرا شوند بسیار مشکل است ( برخلاف روش کارنامه )
  4. سربار انجام عملیات تثبیت زیاد است.

با توجه به مقایسه اجمالی این دو رویکرد، در سیستم های بانک اطلاعات عموما از روش کارنامه برای انجام ترمیم استفاده می شود.

با سپاس از توجه و اعتماد شما

درگاه پرداخت ePayBank.ir

 

 

Transaction recovery algorithms

To ensure the integrity and reliability, completeness Database or Database and Transaction properties apply in the event of failure , the algorithm that we use generally involves two steps are as follows :

First, during normal operation , the information for restoration ( after failure ) , they need to be recorded somewhere .
Second, after the failure ( when the system comes back up ) , using data recorded in the previous step , the properties can be applied to the integrity and reliability of transactions .
Durability of the effect of the transaction was to be permanent .

The integrity of the property , the transaction has no effect on the half halt is put to the database .

The second phase of the restoration algorithm , each transaction that is conducted Commit to redo it again ( re- run effects on the permanent database ) and any transaction that have toppled or Undo to cancel . We assume that transactions are sequential .

Restoration algorithms are divided into two general approaches :

Or Log Based Approach Workbook
CC approach Shadow Paging
Workbook approach has disadvantages , the main ones are:

 An enlargement of the workbook file
Be time consuming to search the record
Likelihood of repeat transactions that already have them repeated .
Increased costs due to database updates to work with the media.
To fix or improve the disadvantages of the proposed methods including the best use of checkpoints or checkpoint is. In this way, alternating periods of time, given the normal operation of the system, the work done on the database ( to date ) of the definitive moments in which we are called system checkpoints .

The following operations are performed at each point of inspection :

Transcript of records (which were written in the buffer system during normal operation ) are moved to stable storage .
Modified data in the buffer are transferred to the disk .
Inspection records are called records <checkpoint> structure .
With failure , the beginning of the record, we do not start reading it until the last operation on the database checkpoints are definitive . After the repair is only relevant portions of the record after the last record are inspected .

File Management Workbook workbook or log truncation cutting techniques we use to record from the beginning sections have already been finalized and they do not need to remove the charges. In other words, the transcripts of both active and archived is Qmt . Active part , is of limited size and overflowed its archive is transmitted periodically . The archives are usually old and Bdrdnkhhvr Overflow notes that should be thrown away , but we Sure enough, they kept in the archives of the second and third . Archives can be stored on magnetic tape .

CC approach

Before making changes ( prior to the execution of transactions ) a copy of pages required to prepare a database called Shadow Shadow version of it in non-volatile storage media charges. The original version of the changes desired transaction is done only on the current version or Current name. If the transaction was finished, the current version can be considered as a new database and repel the shadow copies . But if the transaction could not be done, the current version of the slave database will be equal to the shadow copy .

The approach benefits the transcript :

Overhead involved in writing records is a record .
Restore operation is very simple .
Disadvantages copy approach :

To implement it, we need to record .
Copy the information from the bank is very expensive ( even with optimizations performed in this area ).
The development of this method to the case of concurrent transactions can be implemented very difficult ( unlike the repertoire of methods )
Consolidated operating overhead is high.
According to a brief comparison of these two approaches , database systems typically record the method used to perform the repair .

Thanks for your attention and trust

Payment gateway ePayBank.ir

Bank transactions , Payment gateway Log Based, Shadow Paging, repair algorithms transaction, transaction recovery algorithms , transaction , repairing , restoring transaction copy approach , the workbook approach , reliability transactions, transaction integrity