Skip to content
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

[#312] Wrong detection of heurestic transactions with WildFly 34 Beta #313

Merged
merged 1 commit into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading