skip to content

Sampler Error Actions

What the engine does once a sample fails - carry on, skip the iteration, kill the thread or stop the test - plus deliberate pauses and serialised sections, and why there is no retry element.

on this pageshow

explore

questions

6

In JMeter's Thread Group, what does the 'Action to be taken after a Sampler error' setting do?

level: juniorimportance: must knowfreq 74%

answer

  1. One policy per Thread Group, not per sampler
  2. Five radio buttons, one default
  3. Failed assertions count as errors too
  4. The JMX key ends in on_sample_error
  5. Default value is the word continue

basics

~20 s

It picks what a thread does when one of its samplers fails: Continue, Start Next Thread Loop, Stop Thread, Stop Test or Stop Test Now. Continue is the default, and a failed assertion counts as an error.

solid answer

~50 s

The setting is a row of five radio buttons on every Thread Group, titled **Action to be taken after a Sampler error**. It is a group-wide policy: it fires for *any* sampler inside that Thread Group whose result ends up unsuccessful, whether the request itself failed or an assertion under it marked the sample failed. The five choices are `Continue` (ignore it and carry on to the next sampler), `Start Next Thread Loop` (abandon the rest of this thread-group iteration and begin the next one), `Stop Thread` (this virtual user exits), `Stop Test` (the whole run winds down once in-flight samples finish) and `Stop Test Now` (the whole run stops abruptly, interrupting samplers where it can). The default is `Continue`, stored in the `.jmx` as `<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>`. In every case the failing sample is still recorded first — the action is applied after post-processors, assertions and listeners have run.

code

xml · 8 lines
xml
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Shoppers" enabled="true">
  <stringProp name="ThreadGroup.on_sample_error">startnextloop</stringProp>
  <elementProp name="ThreadGroup.main_controller" elementType="LoopController"
               guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller">
    <boolProp name="LoopController.continue_forever">false</boolProp>
    <stringProp name="LoopController.loops">3</stringProp>
  </elementProp>
</ThreadGroup>

go deeper

for a junior

Recall the panel name, the five choices and that Continue is the default. Be able to point at the Thread Group as the place the setting lives.

for a middle

Explain that the trigger is the sample's final verdict after assertions, and that the action is applied only once the result has already reached the listeners.

for a senior

Show you pick a different value for a setup group than for the main load group, and that you know one thread's Stop Test ends everyone's run.

for a principal

Own the blast-radius question: which groups may abort a run at all, and whether an all-or-nothing group policy or a conditional element expresses the intent better.

## Where the setting lives Every Thread Group in Apache JMeter 6.0.0 carries a titled panel, **Action to be taken after a Sampler error**, holding five mutually exclusive radio buttons. It is not a property of a sampler and not a property of the Test Plan: it is one policy per Thread Group, applied to every sampler that group runs. In the saved plan it is a single string property on the group: ```xml <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Shoppers"> <stringProp name="ThreadGroup.on_sample_error">continue</stringProp> ``` The five accepted values are `continue`, `startnextloop`, `stopthread`, `stoptest` and `stoptestnow`. When the property is absent the engine falls back to `continue`, so a plan that never touched the setting behaves as if `Continue` were chosen. ## What counts as a Sampler error The trigger is the sample's final verdict, not the transport outcome. JMeter runs the sampler, hands the result to the post-processors in scope, then to the assertions in scope, and only then looks at whether the result is successful. That means all of these fire the action: - a request that never completed — connection refused, reset, read timeout; - a response the sampler itself judged unsuccessful; - a perfectly delivered response that a **Response Assertion**, **JSON Assertion** or any other assertion under that sampler marked failed. The component reference states it plainly: the action is taken 'either because the sample itself failed or an assertion failed'. ## What each choice does | Choice | `.jmx` value | Effect | |---|---|---| | `Continue` | `continue` | Nothing changes; the thread moves to the next sampler. | | `Start Next Thread Loop` | `startnextloop` | The remainder of this thread-group iteration is abandoned; the thread begins its next iteration. | | `Stop Thread` | `stopthread` | This one thread ends. Other threads are untouched. | | `Stop Test` | `stoptest` | Every thread is asked to stop; each finishes the sampler it is in and exits. | | `Stop Test Now` | `stoptestnow` | Every thread is told to stop and its in-flight sampler is interrupted where the sampler supports it. | ## The order that matters A common misreading is that a stop action discards the sample that caused it. It does not. Inside the thread loop the sequence for one sampler is: 1. serve the timers in scope; 2. run the sampler; 3. run the post-processors in scope; 4. run the assertions in scope, which may flip the verdict to failed; 5. notify the listeners — so the row reaches the results file; 6. *then* apply the error action. So the failing login, checkout or search sample is written to the JTL with its real verdict before the thread or the test is brought down. What you lose is everything the thread would have done *after* that sample. ## Practical notes - The setting is inherited by nothing. Each Thread Group in the plan has its own, and a plan with a setUp group, a main group and a tearDown group has three independent choices to make. - Third-party `jpgc` thread groups — the Concurrency, Arrivals, Stepping and Ultimate variants shipped by the plugins project, not by the Apache download — extend the same base class and carry the same `ThreadGroup.on_sample_error` property, so the policy travels with them. - If you need the reaction to apply to one sampler rather than the whole group, this field is the wrong tool; JMeter has a separate element for that, and a Flow Control Action under an If Controller gives you a conditional version. Because `Continue` is the default and it is silent, a plan whose author never opened this panel will keep every failing thread marching through the rest of its iteration — which is usually fine for a load run and almost never fine for a setup or smoke group.

  • If the sampler returned a 200 but a Response Assertion under it failed, does the Thread Group action still fire?
    Yes. JMeter runs the assertions before it inspects the verdict, so an assertion failure makes the sample unsuccessful and the group's error action is applied exactly as it would be for a connection reset.
  • Does choosing Stop Thread mean the failing sample is missing from the results file?
    No. Listeners are notified before the stop is applied, so the failing row is written with its real verdict. Only the samplers the thread would have run afterwards are lost.

saying these in an interview costs you the question

  • Thinking the setting lives on the sampler rather than the Thread Group
  • Believing it only reacts to transport failures, not assertion failures
  • Assuming the default is Stop Thread rather than Continue
  • Claiming a stop action discards the sample that triggered it
  • Expecting one Thread Group's choice to apply to the whole plan
open as a page

In JMeter, how do the Stop Thread, Stop Test and Stop Test Now error actions differ?

level: middleimportance: must knowfreq 63%

basics

~20 s

Stop Thread ends only the thread that failed. Stop Test asks every thread to finish its current sample and exit. Stop Test Now also tells them to stop but interrupts the samplers still in flight.

open as a page

A JMeter thread's login sampler fails, yet it keeps running the checkout samplers. How do you stop that?

level: seniorimportance: should knowfreq 56%

basics

~20 s

That is the default Continue policy. Set the Thread Group's error action to Start Next Thread Loop, or put a Flow Control Action under an If Controller so the stop fires only on the login.

open as a page

In JMeter, what does the httpclient4.retrycount property retry, and what does it not?

level: seniorimportance: should knowfreq 48%

basics

~20 s

It retries transport failures only - an I/O error while the request is executing, on idempotent methods. It never re-sends a request the server answered, and never re-runs a sampler an assertion failed. It defaults to 0.

open as a page

Across a team's JMeter plans, how would you decide each Thread Group's sampler-error action?

level: principalimportance: should knowfreq 38%

basics

~20 s

Treat it as a blast-radius decision. Let setUp groups fail fast with Stop Test, keep main load groups on Continue so the run holds its schedule, and express any narrower stop as a visible element rather than a group-wide policy.

open as a page

What does JMeter's Result Status Action Handler add over the Thread Group's error action?

level: middleimportance: nice to knowfreq 34%

basics

~20 s

It applies an error action only to the samplers in its own scope, not the whole Thread Group, and adds two choices the group panel lacks: Break Current Loop and Go to the next iteration of Current Loop.

open as a page