In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces the relevant knowledge of "how to understand PostgreSQL transaction management". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
1. The Transaction System
README
Src/backend/access/transam/READMEThe Transaction System== transaction system PostgreSQL's transaction system is a three-layer system. The transactions of The bottom layerimplements low-level transactions and subtransactions, on top of which reststhe mainloop's control code and which in turn implements user-visibletransactions and savepoints.PostgreSQL are divided into three tiers. The bottom layer implements low-level transactions and sub-transactions, on which the main loop control code resides, while the main loop implements user visibility transactions and savepoints such as middle layer of code is called by postgres.c before and after theprocessing of each query, or after detecting an error: StartTransactionCommand CommitTransactionCommand AbortCurrentTransactionMeanwhile. The user can alter the system's state by issuing the SQL commandsBEGIN, COMMIT, ROLLBACK, SAVEPOINT, ROLLBACK TO or RELEASE. The traffic copredirects these calls to the toplevel routines BeginTransactionBlock EndTransactionBlock UserAbortTransactionBlock DefineSavepoint RollbackToSavepoint ReleaseSavepointrespectively. Depending on the current state of the system, these functionscall low level functions to activate the real transaction system: StartTransaction CommitTransaction AbortTransaction CleanupTransaction StartSubTransaction CommitSubTransaction AbortSubTransaction CleanupSubTransaction before and after processing a query or when an error is detected, postgres.c calls the middle-tier code: StartTransactionCommand CommitTransactionCommand AbortCurrentTransaction changes the system state by executing the BEGIN/COMMIT/ROLLBACK/SAVEPOINT/ROLLBACK TO/RELEASE command during this period. The scheduler redirects these calls to the corresponding top-level routine. BeginTransactionBlock EndTransactionBlock UserAbortTransactionBlock DefineSavepoint RollbackToSavepoint ReleaseSavepoint depends on the current system state, and these functions call the underlying functions to activate the real transaction system: StartTransaction CommitTransaction AbortTransaction CleanupTransaction StartSubTransaction CommitSubTransaction AbortSubTransaction CleanupSubTransactionAdditionally, within a transaction, CommandCounterIncrement is called toincrement the command counter, which allows future commands to "see" theeffects of previous commands within the same transaction. Note that this isdone automatically by CommitTransactionCommand after each query inside atransaction block, but some utility functions also do it internally to allowsome operations (usually in the system catalogs) to be seen by futureoperations in the same utility command. (For example, in DefineRelation it isdone after creating the heap so the pg_class row is visible, to be able tolock it.) In addition, within a transaction, calling CommandCounterIncrement increases the command count, which allows future commands to see the impact of previous commands in the same transaction. Note that this action is done automatically by CommitTransactionCommand after completing each query within the transaction block, but some tool functions also implement this function internally to allow certain operations (usually in the system catalog) to be seen by the same tool commands in the future. (for example, in DefineRelation, the lines in pg_class are visible and locking can be performed after creating the heap) For example, consider the following sequence of user commands: for example, consider the following set of user commands: 1) BEGIN2) SELECT * FROM foo3) INSERT INTO foo VALUES (.) 4) COMMITIn the main processing loop, this results in the following function callsequence: in the main processing loop The following sequence of function calls is formed: / StartTransactionCommand -- middle / StartTransaction;-- bottom1) < ProcessUtility
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.