Re: [HACKERS] logical decoding of two-phase transactions
От | Nikhil Sontakke |
---|---|
Тема | Re: [HACKERS] logical decoding of two-phase transactions |
Дата | |
Msg-id | CAMGcDxfc0yWmdkn28UBkyEjdCWqXmNgS2v=cjOgWD39mvvoY+w@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: [HACKERS] logical decoding of two-phase transactions (Nikhil Sontakke <nikhils@2ndquadrant.com>) |
Ответы |
Re: [HACKERS] logical decoding of two-phase transactions
Re: [HACKERS] logical decoding of two-phase transactions |
Список | pgsql-hackers |
Hi all, > > PFA, patch which applies cleanly against latest git head. I also > removed unwanted newlines and took care of the cleanup TODO about > making ReorderBufferTXN structure using a txn_flags field instead of > separate booleans for various statuses like has_catalog_changes, > is_subxact, is_serialized etc. The patch uses this txn_flags field for > the newer prepare related info as well. > > "make check-world" passes ok, including the additional regular and tap > tests that we have added as part of this patch. > PFA, latest version of this patch. This latest version takes care of the abort-while-decoding issue along with additional test cases and documentation changes. We now maintain a list of processes that are decoding a specific transactionID and make it a decode groupmember of a decode groupleader process. The decode groupleader process is basically the PGPROC entry which points to the prepared 2PC transaction or an ongoing regular transaction. If the 2PC is rollback'ed then FinishPreparedTransactions uses the decode groupleader process to let all the decode groupmember processes know that it's aborting. A similar logic can be used for the decoding of uncommitted transactions. The decode groupmember processes are able to abort sanely in such a case. We also have two new APIs "LogicalLockTransaction" and "LogicalUnlockTransaction" that the decoding backends need to use while doing system or user catalog tables access. The abort code interlocks with decoding backends that might be in the process of accessing catalog tables and waits for those few moments before aborting the transaction. The implementation uses the LockHashPartitionLockByProc on the decode groupleader process to control access to these additional fields in the PGPROC structure amongst the decode groupleader and the other decode groupmember processes and does not need to use the ProcArrayLock at all. The implementation is inspired from the *existing* lockGroupLeader solution which uses a similar technique to track processes waiting on a leader holding that lock. I believe it's an optimal solution for this problem of ours. Have added TAP tests to test multiple decoding backends working on the same transaction. Used delays in the test-decoding plugin to introduce waits after making the LogicalLockTransaction call and calling ROLLBACK to ensure that it interlocks with such decoding backends which are doing catalog access. Tests working as desired. Also "make check-world" passes with asserts enabled. I will post this same explanation about abort handling on the other thread (http://www.postgresql-archive.org/Logical-Decoding-and-HeapTupleSatisfiesVacuum-assumptions-td5998294.html). Comments appreciated. Regards, Nikhils -- Nikhil Sontakke http://www.2ndQuadrant.com/ PostgreSQL/Postgres-XL Development, 24x7 Support, Training & Services
Вложения
В списке pgsql-hackers по дате отправления: