{"record":{"id":"b1e29f31eb369cf1","repo":"hyperledger/fabric","slug":"this-function-should-only-be-called-once-on-a-tran","errorCode":null,"errorMessage":"this function should only be called once on a transaction simulator instance","messagePattern":"this function should only be called once on a transaction simulator instance","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/ledger/kvledger/txmgmt/txmgr/tx_simulator.go","lineNumber":198,"sourceCode":") (ledger.QueryResultsIterator, error) {\n\tif err := s.checkBeforePaginatedQueries(); err != nil {\n\t\treturn nil, err\n\t}\n\treturn s.queryExecutor.GetStateRangeScanIteratorWithPagination(namespace, startKey, endKey, pageSize)\n}\n\n// ExecuteQueryWithPagination implements method in interface `ledger.QueryExecutor`\nfunc (s *txSimulator) ExecuteQueryWithPagination(namespace, query, bookmark string, pageSize int32) (ledger.QueryResultsIterator, error) {\n\tif err := s.checkBeforePaginatedQueries(); err != nil {\n\t\treturn nil, err\n\t}\n\treturn s.queryExecutor.ExecuteQueryWithPagination(namespace, query, bookmark, pageSize)\n}\n\n// GetTxSimulationResults implements method in interface `ledger.TxSimulator`\nfunc (s *txSimulator) GetTxSimulationResults() (*ledger.TxSimulationResults, error) {\n\tif s.simulationResultsComputed {\n\t\treturn nil, errors.New(\"this function should only be called once on a transaction simulator instance\")\n\t}\n\tdefer func() { s.simulationResultsComputed = true }()\n\tlogger.Debugf(\"Simulation completed, getting simulation results\")\n\tif s.queryExecutor.err != nil {\n\t\treturn nil, s.queryExecutor.err\n\t}\n\ts.queryExecutor.addRangeQueryInfo()\n\tsimResults, err := s.rwsetBuilder.GetTxSimulationResults()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t// The txSimulator structures need to be cloned so that subsequent RW set additions don't modify these TX simulation results\n\tsimResults.PrivateReads = s.privateReads.Clone()\n\tsimResults.WritesetMetadata = s.writesetMetadata.Clone()\n\treturn simResults, nil\n}\n\n// ExecuteUpdate implements method in interface `ledger.TxSimulator`","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/ledger/kvledger/txmgmt/txmgr/tx_simulator.go#L180-L216","documentation":"Returned by txSimulator.GetTxSimulationResults when it is invoked more than once on the same simulator instance. Simulation results are computed once; a second call would mutate an already-consumed rwset, so the guard rejects it.","triggerScenarios":"Thrown at core/ledger/kvledger/txmgmt/txmgr/tx_simulator.go:198 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Call GetTxSimulationResults exactly once per simulator","Create a new simulator for a repeat simulation"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2736b63f8fd5932511d56fe68b7039d15977f7f6","analyzedAt":"2026-09-04T08:52:36.465Z","contentChangedAt":"2026-09-04T08:52:36.465Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}