dlmarion commented on code in PR #4556:
URL: https://github.com/apache/accumulo/pull/4556#discussion_r1606709087
##########
core/src/main/java/org/apache/accumulo/core/fate/AdminUtil.java:
##########
@@ -341,37 +341,52 @@ private FateStatus getTransactionStatus(ReadOnlyTStore<T>
zs, Set<Long> filterTx
List<TransactionStatus> statuses = new ArrayList<>(transactions.size());
for (Long tid : transactions) {
+ try {
+ zs.reserve(tid);
- zs.reserve(tid);
-
- String txName = (String) zs.getTransactionInfo(tid, Fate.TxInfo.TX_NAME);
+ String txName = (String) zs.getTransactionInfo(tid,
Fate.TxInfo.TX_NAME);
- List<String> hlocks = heldLocks.remove(tid);
+ List<String> hlocks = heldLocks.remove(tid);
- if (hlocks == null) {
- hlocks = Collections.emptyList();
- }
+ if (hlocks == null) {
+ hlocks = Collections.emptyList();
+ }
- List<String> wlocks = waitingLocks.remove(tid);
+ List<String> wlocks = waitingLocks.remove(tid);
- if (wlocks == null) {
- wlocks = Collections.emptyList();
- }
+ if (wlocks == null) {
+ wlocks = Collections.emptyList();
+ }
- String top = null;
- ReadOnlyRepo<T> repo = zs.top(tid);
- if (repo != null) {
- top = repo.getName();
- }
+ String top = null;
+ ReadOnlyRepo<T> repo = zs.top(tid);
+ if (repo != null) {
+ top = repo.getName();
+ }
- TStatus status = zs.getStatus(tid);
+ TStatus status = zs.getStatus(tid);
- long timeCreated = zs.timeCreated(tid);
+ long timeCreated = zs.timeCreated(tid);
- zs.unreserve(tid, 0, TimeUnit.MILLISECONDS);
+ zs.unreserve(tid, 0, TimeUnit.MILLISECONDS);
- if (includeByStatus(status, filterStatus) && includeByTxid(tid,
filterTxid)) {
- statuses.add(new TransactionStatus(tid, status, txName, hlocks,
wlocks, top, timeCreated));
+ if (includeByStatus(status, filterStatus) && includeByTxid(tid,
filterTxid)) {
+ statuses
+ .add(new TransactionStatus(tid, status, txName, hlocks, wlocks,
top, timeCreated));
+ }
+ } catch (Exception e) {
+ // If the cause of the Exception is a NoNodeException, it should be
ignored as this
+ // indicates the transaction has completed between the time the list
of transactions was
+ // acquired and the time the transaction was probed for info.
+ Throwable cause = e;
+ while (cause != null && !(cause instanceof
KeeperException.NoNodeException)) {
+ cause = cause.getCause();
+ }
+ if (cause == null) {
Review Comment:
`cause` will be non-null for any exception in the stack. This could be set
*after* seeing a `NoNodeException`. I'm assuming that you only want to re-throw
an Exception if there is no `NoNodeException` found. If that's the case, then I
think this might need to be re-worked. You could do something like the
following:
```
boolean exceptionFound = false;
Throwable cause = e;
while (cause != null) {
if (cause instanceof NoNodeException) {
exceptionFound = true;
break;
}
cause = cause.getCause();
if (!exceptionFound) {
throw e;
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]