Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix writeable CTE assign reader gang to writer slice.
For the gang allocation, our current implementation required the first allocated gang must be the writer gang. This has several reasons: - For lock holding, Because of our MPP structure, we assign a LockHolder for each segment when executing a query. lockHolder is the gang member that should hold and manage locks for this transaction. On the QEs, it should normally be the Writer gang member. More details please refer to lockHolderProcPtr in lock.c. - For SharedSnapshot among session's gang processes on a particular segment. During initPostgres(), reader QE will try to lookup the shared slot written by writer QE. More details please reger to sharedsnapshot.c. Normally, the writer slice will be assign writer gang first when iterate the slice table. But this is not true for writable CTE (with only one writer gang). For below statement: explain (slicetable) WITH updated AS (update tbl set rank = 6 where id = 5 returning rank) select * from tbl where rank in (select rank from updated); QUERY PLAN -------------------------------------------------------------- Gather Motion 3:1 (slice1; segments: 3) -> Seq Scan on tbl Filter: (hashed SubPlan 1) SubPlan 1 -> Broadcast Motion 1:3 (slice2; segments: 1) -> Update on tbl -> Seq Scan on tbl Filter: (id = 5) Slice 0: Dispatcher; root 0; parent -1; gang size 0 Slice 1: Reader; root 0; parent 0; gang size 3 Slice 2: Primary Writer; root 0; parent 1; gang size 1 If we sill assign writer gang to Slice 1 here, the writer process will execute on reader gang. So, find the writer slice and assign writer gang first.
- Loading branch information
1 parent
91eaeac
commit f124d98
Showing
3 changed files
with
76 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters