-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SNAP-1950 #361
base: snappy/master
Are you sure you want to change the base?
SNAP-1950 #361
Changes from all commits
41252b3
2972e0b
422836d
8f7d0b1
d9f7e43
2baa005
bd34360
9b61ae5
dd37a65
66f00e4
7f98b66
9404c94
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -157,24 +157,45 @@ final void apply(final TXStateProxy tx) { | |
region = baseRegion = null; | ||
} | ||
final int numOps = this.pendingOps.size(); | ||
// take pendingTXRegionStates lock first so that | ||
// GII thread doesn't block on TXRegionState. | ||
//ArrayList<LocalRegion> lockedRegions = new ArrayList<>(); | ||
/*for (LocalRegion r : pendingOpsRegions) { | ||
if (!r.isInitialized() && r.getImageState().lockPendingTXRegionStates(true, false)) { | ||
lockedRegions.add(r); | ||
} | ||
}*/ | ||
boolean lockedPendingTXregionState = false; | ||
for (int index = 0; index < numOps; index++) { | ||
entry = this.pendingOps.get(index); | ||
if (pendingOpsRegion == null) { | ||
region = this.pendingOpsRegions.get(index); | ||
if (region.isUsedForPartitionedRegionBucket()) { | ||
baseRegion = region.getPartitionedRegion(); | ||
} | ||
else { | ||
} else { | ||
baseRegion = region; | ||
} | ||
} | ||
if (txState.isCoordinator()) { | ||
region.waitForData(); | ||
} | ||
txrs = txState.writeRegion(region); | ||
if (txrs != null) { | ||
txState.applyPendingOperation(entry, lockFlags, txrs, region, | ||
baseRegion, eventTemplate, true, Boolean.TRUE, this); | ||
if (!region.isInitialized() && | ||
region.getImageState().lockPendingTXRegionStates(true, false)) { | ||
//lockedRegions.add(region); | ||
lockedPendingTXregionState = true; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cleaner to do "boolean lockPendingTXRegionState = !region.isInitialized() && region.getImageState().lock..." |
||
try { | ||
txrs = txState.writeRegion(region); | ||
if (txrs != null) { | ||
txState.applyPendingOperation(entry, lockFlags, txrs, region, | ||
baseRegion, eventTemplate, true, Boolean.TRUE, this); | ||
} | ||
} finally { | ||
//for (LocalRegion r : lockedRegions) { | ||
if (lockedPendingTXregionState) { | ||
region.getImageState().unlockPendingTXRegionStates(true); | ||
lockedPendingTXregionState = false; | ||
} | ||
} | ||
} | ||
} finally { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -150,7 +150,14 @@ public TXRegionState(final LocalRegion r, final TXState tx) { | |
this.expiryReadLock = r.getTxEntryExpirationReadLock(); | ||
this.isValid = true; | ||
|
||
if (!r.isInitialized() && r.getImageState().lockPendingTXRegionStates(true, false)) { | ||
|
||
// check if lock already taken by the same thread | ||
// in that case don't take lock | ||
ImageState imgState = r.getImageState(); | ||
|
||
//boolean alreadyLocked = imgState.isWriteLockedBySameThread(); | ||
if (!r.isInitialized() | ||
&& (imgState.lockPendingTXRegionStates(true, false))) { | ||
try { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the lock can be taken multiple times by same thread, won't it be better to make this a ReentrantReadWriteLock instead of "isWriteLockedBySameThread" check? The block inside will add TXRegionState in pending list and initialize pendingTXOps lists which I think is required. |
||
if (!r.getImageState().addPendingTXRegionState(this)) { | ||
this.pendingTXOps = null; | ||
|
@@ -160,9 +167,9 @@ public TXRegionState(final LocalRegion r, final TXState tx) { | |
this.pendingTXLockFlags = new TIntArrayList(); | ||
} | ||
} finally { | ||
r.getImageState().unlockPendingTXRegionStates(true); | ||
//if (!alreadyLocked) | ||
r.getImageState().unlockPendingTXRegionStates(true); | ||
} | ||
|
||
} else { | ||
this.pendingTXOps = null; | ||
this.pendingTXLockFlags = null; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commented portion can be removed to avoid confusion