Topic: Locks in a business layer
All kind Now I will sound a problem, for certain I not the first who face it also decisions for a long time already are known, but is visible they to me did not come across or were not remembered. It is a question of the task of support of an invariance of a state of business objects till the end of business operation in the multiple user environment. We present that there is any operation, on business to rules it can be successfully fulfilled only at a certain state of any objects. How we implement it? In the code at first we read these objects, we check their state and if it corresponds to business rules we fulfill operation. In the multiple user environment here there can be problems: the state of checked objects can change between reading of objects and operation performance that as a matter of fact it leads to performance of operation with violation of business rules. Gravity of such violation can vary is is sometimes admissible, and sometimes is not present (on one place is sold two tickets). For avoidance of such situation it is logical to fulfill lock of the read objects till the end of operation so that anybody another could not change their state. Here there is no speech about check a state of the changeablest object - the decision through "optimistic lock" is known. I speak about stability of a state of other logically bound entities, which do not change operation. The first decision which basically already works, this usage of serializable-transactions on basis. Here as a matter of fact all locks are fulfilled by basis. Scales and volume of locks in basis as a whole that somehow it is necessary to affect them densely to sit down structure of basis and requests. This decision has still lacks: appear in process of growth of loading and an amount of the involved tables, does not envelop the data which are not read from basis (are in - reference manuals). What other decisions can advise? To write the lock manager? There are examples? Technologies and architecture:.NET, Desktop Client - WCF services on IIS, EF - MS Sql Server, there is no horizontal scaling.