Plan for transaction semantics

The DataBlade® module code runs in SQL transactions. A transaction is a single, atomic, independent sequence of client/server interactions.

For example, inside a transaction, a user can search a table for all the cities that overlap Los Angeles. In a separate transaction, some other user can change the boundaries of Los Angeles, as outlying areas are incorporated into the city. The two operations are independent of one another. Each user is isolated from the changes made by the other until the next transaction begins.

You must define DataBlade module code to be stateless and not based on the assumption that any particular value persists across user transactions. For example, a DataBlade module that does text matching might provide two services: one to find all documents that contain a particular set of keywords and another to highlight the matching keywords in the documents.

If a user first runs a query to find matching documents and then runs a separate query to highlight the matches, the second operation cannot rely on any cached results from the first. This is because some document contents might have changed. In addition, because your database server is a multiuser system, different users can run the same routines at the same time. There is no way to guarantee that saved results belong to a particular query.

To ensure that you design systems that operate correctly in this environment, ask the following questions:
  • Are any of the routines based on an assumption that results from previous user actions are still valid?
  • Do I try to cache results for reuse?
  • What happens if two users run the same routine on the same table simultaneously?