Skip to content

Commit

Permalink
Merge pull request #313 from jmfinelli/issue_312
Browse files Browse the repository at this point in the history
[#312] Wrong detection of heurestic transactions with WildFly 34 Beta
  • Loading branch information
yersan authored Oct 3, 2024
2 parents 3e8e109 + fb5b556 commit 879b410
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
37 changes: 22 additions & 15 deletions controllers/transaction_recovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (

var (
recoveryErrorRegExp = regexp.MustCompile("ERROR.*Periodic Recovery")
heuristic_types = [5]string{"HEURISTIC", "HEURISTIC_ROLLBACK", "HEURISTIC_COMMIT", "HEURISTIC_MIXED", "HEURISTIC_HAZARD"}
)

const (
Expand Down Expand Up @@ -152,24 +153,30 @@ func (r *WildFlyServerReconciler) checkRecovery(reqLogger logr.Logger, scaleDown
}
// Is the number of in-doubt transactions equal to zero?
transactions := jsonResult["result"]
txnMap, isMap := transactions.(map[string]interface{}) // typing the variable to be a map of interfaces
// typing the variable to be a map of interfaces
txnMap, isMap := transactions.(map[string]interface{})
if isMap && len(txnMap) > 0 {

// Check for HEURISTIC transactions
jsonResult, err := wfly.ExecuteMgmtOp(scaleDownPod, wfly.MgmtOpTxnReadHeuristic)
if err != nil {
return genericError, "", fmt.Errorf("Cannot read HEURISTIC transactions from the log store of the pod %v, error: %v", scaleDownPodName, err)
}
if !wfly.IsMgmtOutcomeSuccesful(jsonResult) {
return genericError, "", fmt.Errorf("Cannot read HEURISTIC transactions from the log store of the pod %v", scaleDownPodName)
}
// Is the number of HEURISTIC transactions equal to zero?
transactions := jsonResult["result"]
heuristicTxnArray, isArray := transactions.([]interface{}) // typing the variable to be an array of interfaces
if isArray && len(heuristicTxnArray) > 0 {
retString := fmt.Sprintf("There are HEURISTIC transactions in the log store of the pod %v. Please, resolve them manually, "+
"transaction list: %v", scaleDownPodName, heuristicTxnArray)
return heuristic, retString, nil
for _, heuristic_type := range heuristic_types {
jsonResult, err := wfly.ExecuteMgmtOp(scaleDownPod, fmt.Sprintf(wfly.MgmtOpTxnReadHeuristicPattern, heuristic_type))
if err != nil {
return genericError, "", fmt.Errorf("Cannot read %s transactions from the log store of the pod %v, error: %v", heuristic_type, scaleDownPodName, err)
}
if !wfly.IsMgmtOutcomeSuccesful(jsonResult) {
return genericError, "", fmt.Errorf("Cannot read %s transactions from the log store of the pod %v", heuristic_type, scaleDownPodName)
}

// Is the number of HEURISTIC transactions equal to zero?
transactions := jsonResult["result"]
// typing the variable to be an array of interfaces
heuristicTxnArray, isArray := transactions.([]interface{})

if isArray && len(heuristicTxnArray) > 0 {
retString := fmt.Sprintf("There are %s transactions in the log store of the pod %v. Please, resolve them manually, "+
"transaction list: %v", heuristic_type, scaleDownPodName, heuristicTxnArray)
return heuristic, retString, nil
}
}

retString := fmt.Sprintf("A recovery scan is needed as the log store of the pod %v is not empty, "+
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/wildfly_mgmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var (
// MgmtOpTxnRead is a JBoss CLI command for reading transaction log store
MgmtOpTxnRead = "/subsystem=transactions/log-store=log-store:read-children-resources(child-type=transactions,recursive=true,include-runtime=true)"
// MgmtOpTxnReadHeuristic is a JBoss CLI command for scanning the log store in search of transactions in HEURISTIC status
MgmtOpTxnReadHeuristic = "/subsystem=transactions/log-store=log-store/transactions=*/participants=*:query(where={\"status\"=\"HEURISTIC\"}"
MgmtOpTxnReadHeuristicPattern = "/subsystem=transactions/log-store=log-store/transactions=*/participants=*:query(where={\"status\"=\"%s\"}"
// MgmtOpTxnRecoverySocketBindingRead is a JBoss CLI command for reading name of recovery socket binding
MgmtOpTxnRecoverySocketBindingRead = "/subsystem=transactions:read-attribute(name=socket-binding)"
// MgmtOpSocketBindingRead is a JBoss CLI command for reading all data on the socket binding group
Expand Down

0 comments on commit 879b410

Please sign in to comment.