Post views:
1
Google this topic and you may find a lot of information on what distributed transactions are. How they work and when to use them. Unfortunately, good examples of how they behave in the real world seem to be few and far between. If you’ve never used it before, or just want some clarification on a specific detail, you’re in luck. We’ve done the research for you!
Here are 6 facts you might not know about distributed transactions:
1. They do not automatically commit data across multiple databases/platforms
If your application communicates with two different machines (or even servers). It’s quite possible that there will be an error when writing the update saying that you can’t write both at the same time.all of a sudden because of these data not on the same machine. This doesn’t have to be a problem, as you can always write everything to one side first and then the other. However, if you do this, there may be some issues with your application. It happens afterwards because of any changes. The second machine may not recognize the “sending” side unless reapplied.
2. They don’t magically turn N layers into 2 layers
A common misconception about distributed transactions is that this is only necessary when your application needs to access two or more different pieces of data to perform an update. If you find yourself thinking this way, stop immediately. The name of the game here is not how many layers your app actually has, but whether it is possible. Two/multiple data sources can be updated within the same unit of work.
3. They don’t save your data from network failures
One of the cited usage experts Distributed transaction Yes they are able to recover from a failed network connection. Via savepoints (locking changes to each piece of data by timestamp). Then rollback or try again later when the connection is re-established. This is not always true. For example, if you issue two commands in transaction A, issue one command in transaction B. and power down before anything is done, then not only all commands will be rolled back. But they won’t even be tried until everything else is also done downloading/uploading/etc over the network, because again your app doesn’t know what state things are in.
4. They do work with millisecond resolution
Another misconception about distributed transactions is that they only get updates. Every few seconds, because the network is too slow to give you any other information. It’s also not true: SQL Server, for example, uses something called snapshot isolation. Lock records at a much lower level (usually 1ms or less). The result is that even if your application and database take a few minutes to communicate. Unless you happen to change another piece of data on a different server within the same millisecond window, from your perspective everything will behave as if it happened instantaneously (you will see all changes at once).
5. Savepoints can be closed
If you want a very high throughput application, you probably don’t want to use savepoints. If they’re not being used, then why keep them? under these circumstances, SQL The server has a nifty little option called NOLOCK that can be applied to any query. Doing this will tell the server to return all data as is, regardless of how others use it. Basically turning off savepoints completely on multiple machines. This is bad because the same row could be read by two different servers. Each time will result in an update conflict (even if there is no update, there may be an insert conflict). To prevent these problems, try setting up a session with a unique transaction ID. Or lock everything in total instead of row by row.
6. They don’t require a lot of memory
Another common misconception is that distributed transactions require a lot of RAM (on both servers) to work properly. This is not always true: SQL Server actually creates something called a virtual log file. Thanks for the wonders of virtualization. Only take up the space you need at any given time (all “extra” space goes back to your actual storage pool). In other words, if you’re worried about how much RAM you need, don’t worry. It’s not as big a problem as everyone thinks it is.
in conclusion:
Depending on what you’re actually trying to accomplish, distributed transactions might not always be the best practice. If you stick to the most basic data types (i.e. text, numbers, and dates), everything will work in your favor. If nothing else, you won’t lose sleep over this topic. To know more visit the website – https://www.datanumen.com



