skip to content

In JMeter, why can two CSV Data Set Config elements naming one file consume it twice?

level: seniorimportance: nice to knowfreq 26%

answer

  1. Same file, two different spellings
  2. The lookup key is not the inode
  3. One log line per reader opened

basics

~20 s

JMeter keys the open file by the Filename string plus the Sharing mode suffix, not by the resolved file on disk. So logins.csv and ./logins.csv are two keys, and each gets its own reader starting at line one.

solid answer

~40 s

JMeter's `FileServer` stores one open reader per **alias**, and a `CSV Data Set Config` builds that alias from the `Filename` value exactly as typed plus whatever suffix `Sharing mode` adds. The alias is not a canonical path and not an inode, so `logins.csv` in one element and `./logins.csv` in another are two distinct keys onto the same bytes. Each reserves its own entry and starts at line 1, so a 10,000-row credential file is walked twice and half your logins duplicate the other half. On a case-insensitive filesystem `Logins.CSV` is a third key. `Recycle on EOF` and `Stop thread on EOF` then apply per reader, so one pointer can stop its threads while the other is halfway down the file. Use one identical string, or one element.

go deeper

for a junior

Recall that the Filename you type is what JMeter uses to identify the open file, so two elements must spell it identically if they are meant to share the data.

for a middle

Explain that the alias is the Filename string plus a Sharing mode suffix, and that a distinct alias means a distinct reader starting at line 1, whatever the paths resolve to on disk.

for a senior

Spot it from the run: duplicated rows despite All threads, or one group stopping at end of file while another continues. Know the Stored: log lines let you count readers before you go hunting further.

for a principal

Own the review rule: a shared data file should have one owning element, or one exact path string reused everywhere, so nobody has to reason about aliasing to know how many times a pool is consumed.

## The key is the string you typed JMeter opens a data file through a `FileServer` that stores one entry per **alias**, and for a **CSV Data Set Config** that alias is built from the `Filename` value exactly as it appears in the element, plus whatever suffix `Sharing mode` adds. It is not the canonical path, not the resolved `File`, and not the inode. Two elements whose `Filename` strings differ by so much as a leading `./` therefore reserve two independent entries, each with its own reader positioned at line 1. The manual states the consequence directly: if the same physical file is referenced as `csvdata.txt` in one element and `./csvdata.txt` in another, JMeter treats them as different files. On a filesystem that ignores case, `logins.csv` and `Logins.CSV` are two more distinct keys onto one file. ## Where a relative Filename resolves from - An absolute path is used as given. - A relative path that exists relative to the process's working directory is used as given. - Otherwise it is resolved against JMeter's base directory, which for a run launched from a `.jmx` file is that script's own directory. So the same relative string can resolve differently depending on where JMeter was started, while still being one alias — and two different strings can resolve to one file while being two aliases. The string decides sharing; the resolution decides which bytes you get. ## What a second reader actually costs - The 10,000 credential rows are consumed twice, so half your logins are duplicates of the other half. - `Recycle on EOF` and `Stop thread on EOF` now apply independently to each reader, so one pointer can reach the end and stop its threads while the other is only halfway down the file. - Both readers hold the file open for the whole run, and each keeps its own buffered position. - A per-run row budget calculated from one pass through the file is silently wrong by a factor of two. ## Spotting it JMeter logs one `Stored:` line per distinct alias when the file is first reserved — `Stored: <filename>` when the alias equals the filename, and `Stored: <filename> Alias: <alias>` when a suffix was added. Counting those lines for your data file tells you exactly how many readers the run opened. If you expected one and see two, the two elements are not sharing. ## The first element to reserve an alias sets its terms The entry is created by whichever element reserves that alias first, and it carries the `File encoding` from that element. A second element with the same `Filename` but a different `File encoding` gets neither its own reader nor its own encoding — it joins the existing entry and reads with the first element's setting. The same holds for the header line, which is read and cached once per alias. ## Keeping one pointer 1. Use one identical `Filename` string in every element that must share the file — copy and paste it rather than retyping. 2. Better, keep a single `CSV Data Set Config` in a scope both consumers can see, instead of two elements. 3. If two elements must exist, give them the same free-typed `Sharing mode` identifier as well, so the suffix matches too. 4. Check the `Stored:` lines in the log on the first run of any plan whose row budget matters.

  • Where does JMeter resolve a relative CSV Data Set Config Filename from?
    An absolute path is used as given, as is a relative path that exists relative to the process working directory. Otherwise it resolves against JMeter's base directory, which for a run launched from a .jmx file is that script's own directory.
  • What in the JMeter log tells you a second reader was opened for the same file?
    One 'Stored:' line is logged per distinct alias when the file is first reserved, naming the filename and, where a suffix was added, the alias too. Counting those lines for your data file gives you the number of readers the run opened.

saying these in an interview costs you the question

  • Says JMeter canonicalises the path so both spellings share one reader.
  • Assumes two elements naming one file always share its file pointer.
  • Thinks Sharing mode All threads makes the Filename spelling irrelevant.
  • Believes a relative Filename always resolves against the JMeter install directory.
  • Expects a duplicate-file warning when two elements open the same file.