Too many open files due to TTree friends

Dear ROOTers,

I generate 2 new trees (teventvoltage and teventadc) in 2 new files (Coarse2_voltage.root, Coarse2_adc.root) from teventefield tree in Coarse2.root. I generate voltage before adc.

When I try to get stuff from teventadc, I get Too many open files error:

[lewhoo@lwpcomp3 data_challenge1_pm_lwp]$ root -l Coarse2_adc.root 
root [0] 
Attaching file Coarse2_adc.root as _file0...
(TFile *) 0x36f3a80
root [1] teventadc->Scan("trace_0[3]")
***********************************
*    Row   * Instance * trace_0[3 *
***********************************
SysError in <TFile::TFile>: file /data/GRAND/data_challenge1_pm_lwp/Coarse2_adc.root can not be opened for reading Too many open files
SysError in <TFile::TFile>: file /data/GRAND/data_challenge1_pm_lwp/Coarse2.root can not be opened for reading Too many open files
SysError in <TFile::TFile>: file /data/GRAND/data_challenge1_pm_lwp/Coarse2.root can not be opened for reading Too many open files
SysError in <TFile::TFile>: file /data/GRAND/data_challenge1_pm_lwp/Coarse2.root can not be opened for reading Too many open files
*        0 *        0 *         2 *
*        0 *        1 *         2 *
*        0 *        2 *         2 *

I think this is to friends added to the tree, because when I don’t add them, everything works fine.

The teventvoltage has teventefield and teventadc as friends. The teventadc has teventefield and teventvoltage as friends.

Am I doing something wrong, or did I stumble upon a bug?

ROOT Version: 6.26.02
Platform: Fedora 35
Compiler: Not Provided


Coarse2.root (867.7 KB)
Coarse2_adc.root (238.2 KB)
Coarse2_voltage.root (2.1 MB)

Somehow the code is still missing a protection against circular dependency in this case.
Namely (at least) the in Coarse2_adc.root the tree teventadc has friends in the other 2 files * AND * the tree teventvoltage in the file Coarse2_voltage.root also has the other 2 files as friends (so including Coarse2_adc.root). As a consequence there an infinite recursive (file1 open file2 which open file which open file2 etc.); the code is supposed to prevent this issue but is not effective here.

To work around the issue, make sure that the relationship are not circular.

I suspected that. However, that makes me think what is wrong with the logic of my approach.

I want GetEntry() on teventadc load an entry from teventvoltage. And I want GetEntry on teventvoltage to load an entry from teventadc. Is it that uncommon?

I think the difference compare to the usual and/or what we tested is that the trees are connected via their filename rather than live. If that is the case then you can work around the issue by recording only the connection teventadc has teventvoltage as friend on the file and adding at runtime the backward connection.

That said, the way it was more or envisioned is that the user would access the data from the main tree and the friend tree always through the main tree (eg. the one in Coarse2.root). That way you have an acyclic graph and all the data is always available.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.