Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
a31ff707
Commit
a31ff707
authored
Jun 07, 2011
by
Heikki Linnakangas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make ascii-art in comments pgindent-safe, and some other formatting changes.
Kevin Grittner
parent
fc1286d3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
13 deletions
+17
-13
src/backend/storage/lmgr/predicate.c
src/backend/storage/lmgr/predicate.c
+17
-13
No files found.
src/backend/storage/lmgr/predicate.c
View file @
a31ff707
...
@@ -3814,7 +3814,7 @@ FlagRWConflict(SERIALIZABLEXACT *reader, SERIALIZABLEXACT *writer)
...
@@ -3814,7 +3814,7 @@ FlagRWConflict(SERIALIZABLEXACT *reader, SERIALIZABLEXACT *writer)
SetRWConflict
(
reader
,
writer
);
SetRWConflict
(
reader
,
writer
);
}
}
/*
/*
----------------------------------------------------------------------------
* We are about to add a RW-edge to the dependency graph - check that we don't
* We are about to add a RW-edge to the dependency graph - check that we don't
* introduce a dangerous structure by doing so, and abort one of the
* introduce a dangerous structure by doing so, and abort one of the
* transactions if so.
* transactions if so.
...
@@ -3823,13 +3823,14 @@ FlagRWConflict(SERIALIZABLEXACT *reader, SERIALIZABLEXACT *writer)
...
@@ -3823,13 +3823,14 @@ FlagRWConflict(SERIALIZABLEXACT *reader, SERIALIZABLEXACT *writer)
* in the dependency graph:
* in the dependency graph:
*
*
* Tin ------> Tpivot ------> Tout
* Tin ------> Tpivot ------> Tout
*
rw rw
* rw rw
*
*
* Furthermore, Tout must commit first.
* Furthermore, Tout must commit first.
*
*
* One more optimization is that if Tin is declared READ ONLY (or commits
* One more optimization is that if Tin is declared READ ONLY (or commits
* without writing), we can only have a problem if Tout committed before Tin
* without writing), we can only have a problem if Tout committed before Tin
* acquired its snapshot.
* acquired its snapshot.
*----------------------------------------------------------------------------
*/
*/
static
void
static
void
OnConflict_CheckForSerializationFailure
(
const
SERIALIZABLEXACT
*
reader
,
OnConflict_CheckForSerializationFailure
(
const
SERIALIZABLEXACT
*
reader
,
...
@@ -3842,32 +3843,34 @@ OnConflict_CheckForSerializationFailure(const SERIALIZABLEXACT *reader,
...
@@ -3842,32 +3843,34 @@ OnConflict_CheckForSerializationFailure(const SERIALIZABLEXACT *reader,
failure
=
false
;
failure
=
false
;
/*
/*
------------------------------------------------------------------------
* Check for already-committed writer with rw-conflict out flagged
* Check for already-committed writer with rw-conflict out flagged
* (conflict-flag on W means that T2 committed before W):
* (conflict-flag on W means that T2 committed before W):
*
*
* R ------> W ------> T2
* R ------> W ------> T2
* rw
rw
* rw
rw
*
*
* That is a dangerous structure, so we must abort. (Since the writer
* That is a dangerous structure, so we must abort. (Since the writer
* has already committed, we must be the reader)
* has already committed, we must be the reader)
*------------------------------------------------------------------------
*/
*/
if
(
SxactIsCommitted
(
writer
)
if
(
SxactIsCommitted
(
writer
)
&&
(
SxactHasConflictOut
(
writer
)
||
SxactHasSummaryConflictOut
(
writer
)))
&&
(
SxactHasConflictOut
(
writer
)
||
SxactHasSummaryConflictOut
(
writer
)))
failure
=
true
;
failure
=
true
;
/*
/*
------------------------------------------------------------------------
* Check whether the writer has become a pivot with an out-conflict
* Check whether the writer has become a pivot with an out-conflict
* committed transaction (T2), and T2 committed first:
* committed transaction (T2), and T2 committed first:
*
*
* R ------> W ------> T2
* R ------> W ------> T2
* rw
rw
* rw
rw
*
*
* Because T2 must've committed first, there is no anomaly if:
* Because T2 must've committed first, there is no anomaly if:
* - the reader committed before T2
* - the reader committed before T2
* - the writer committed before T2
* - the writer committed before T2
* - the reader is a READ ONLY transaction and the reader was concurrent
* - the reader is a READ ONLY transaction and the reader was concurrent
* with T2 (= reader acquired its snapshot before T2 committed)
* with T2 (= reader acquired its snapshot before T2 committed)
*------------------------------------------------------------------------
*/
*/
if
(
!
failure
)
if
(
!
failure
)
{
{
...
@@ -3891,7 +3894,7 @@ OnConflict_CheckForSerializationFailure(const SERIALIZABLEXACT *reader,
...
@@ -3891,7 +3894,7 @@ OnConflict_CheckForSerializationFailure(const SERIALIZABLEXACT *reader,
&&
(
!
SxactIsCommitted
(
writer
)
&&
(
!
SxactIsCommitted
(
writer
)
||
t2
->
commitSeqNo
<=
writer
->
commitSeqNo
)
||
t2
->
commitSeqNo
<=
writer
->
commitSeqNo
)
&&
(
!
SxactIsReadOnly
(
reader
)
&&
(
!
SxactIsReadOnly
(
reader
)
||
t2
->
commitSeqNo
<=
reader
->
SeqNo
.
lastCommitBeforeSnapshot
))
||
t2
->
commitSeqNo
<=
reader
->
SeqNo
.
lastCommitBeforeSnapshot
))
{
{
failure
=
true
;
failure
=
true
;
break
;
break
;
...
@@ -3903,16 +3906,17 @@ OnConflict_CheckForSerializationFailure(const SERIALIZABLEXACT *reader,
...
@@ -3903,16 +3906,17 @@ OnConflict_CheckForSerializationFailure(const SERIALIZABLEXACT *reader,
}
}
}
}
/*
/*
------------------------------------------------------------------------
* Check whether the reader has become a pivot with a committed writer:
* Check whether the reader has become a pivot with a committed writer:
*
*
* T0 ------> R ------> W
* T0 ------> R ------> W
* rw
rw
* rw
rw
*
*
* Because W must've committed first for an anomaly to occur, there is no
* Because W must've committed first for an anomaly to occur, there is no
* anomaly if:
* anomaly if:
* - T0 committed before the writer
* - T0 committed before the writer
* - T0 is READ ONLY, and overlaps the writer
* - T0 is READ ONLY, and overlaps the writer
*------------------------------------------------------------------------
*/
*/
if
(
!
failure
&&
SxactIsCommitted
(
writer
)
&&
!
SxactIsReadOnly
(
reader
))
if
(
!
failure
&&
SxactIsCommitted
(
writer
)
&&
!
SxactIsReadOnly
(
reader
))
{
{
...
@@ -3934,7 +3938,7 @@ OnConflict_CheckForSerializationFailure(const SERIALIZABLEXACT *reader,
...
@@ -3934,7 +3938,7 @@ OnConflict_CheckForSerializationFailure(const SERIALIZABLEXACT *reader,
&&
(
!
SxactIsCommitted
(
t0
)
&&
(
!
SxactIsCommitted
(
t0
)
||
t0
->
commitSeqNo
>=
writer
->
commitSeqNo
)
||
t0
->
commitSeqNo
>=
writer
->
commitSeqNo
)
&&
(
!
SxactIsReadOnly
(
t0
)
&&
(
!
SxactIsReadOnly
(
t0
)
||
t0
->
SeqNo
.
lastCommitBeforeSnapshot
>=
writer
->
commitSeqNo
))
||
t0
->
SeqNo
.
lastCommitBeforeSnapshot
>=
writer
->
commitSeqNo
))
{
{
failure
=
true
;
failure
=
true
;
break
;
break
;
...
@@ -3950,8 +3954,8 @@ OnConflict_CheckForSerializationFailure(const SERIALIZABLEXACT *reader,
...
@@ -3950,8 +3954,8 @@ OnConflict_CheckForSerializationFailure(const SERIALIZABLEXACT *reader,
{
{
/*
/*
* We have to kill a transaction to avoid a possible anomaly from
* We have to kill a transaction to avoid a possible anomaly from
* occurring. If the writer is us, we can just ereport() to cause
* occurring. If the writer is us, we can just ereport() to cause
a
*
a
transaction abort. Otherwise we flag the writer for termination,
* transaction abort. Otherwise we flag the writer for termination,
* causing it to abort when it tries to commit. However, if the writer
* causing it to abort when it tries to commit. However, if the writer
* is a prepared transaction, already prepared, we can't abort it
* is a prepared transaction, already prepared, we can't abort it
* anymore, so we have to kill the reader instead.
* anymore, so we have to kill the reader instead.
...
@@ -3962,7 +3966,7 @@ OnConflict_CheckForSerializationFailure(const SERIALIZABLEXACT *reader,
...
@@ -3962,7 +3966,7 @@ OnConflict_CheckForSerializationFailure(const SERIALIZABLEXACT *reader,
ereport
(
ERROR
,
ereport
(
ERROR
,
(
errcode
(
ERRCODE_T_R_SERIALIZATION_FAILURE
),
(
errcode
(
ERRCODE_T_R_SERIALIZATION_FAILURE
),
errmsg
(
"could not serialize access due to read/write dependencies among transactions"
),
errmsg
(
"could not serialize access due to read/write dependencies among transactions"
),
errdetail
(
"Cancelled on identification as a pivot, during write."
),
errdetail
(
"Cancelled on identification as a pivot, during write."
),
errhint
(
"The transaction might succeed if retried."
)));
errhint
(
"The transaction might succeed if retried."
)));
}
}
else
if
(
SxactIsPrepared
(
writer
))
else
if
(
SxactIsPrepared
(
writer
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment