Re: Recovering badly closed file?

From: Philippe Canal <pcanal_at_fnal.gov>
Date: Fri, 22 Jan 2010 12:40:06 -0600


Hi Brett,

The major problem with this file is that it is missing the StreamerInfo objects.
This means that you must provide the StreamerInfo describing the content some
other way.
The easiest way to do so is to read the file with the version of the software that
was used to write it. So in minos01:/var/tmp I sucessfully did:

   TFile *_file0 = TFile::Open("B100112_080001.mbeam-fix.root")     t = BeamMon;
    out = new TFile("copy.root","RECREATE");     t->CloneTree();
    out->Write();

and copy.root is not fully useable.

Note that in v5.26/00 and higher you will get get the error message:

Error in <TBufferFile::ReadClassBuffer>: Could not find the StreamerInfo for version 16 of the class TTree, object skipped at offset 70 Error in <TBufferFile::CheckByteCount>: object of class TTree read too few bytes: 2 instead of 282848

(in previous version it was unfortunately picking the current StreamerInfo rather than complain leading to serious issues.)

Cheers,
Philippe

Brett Viren wrote:
> Hi again,
>
> Brett Viren <bv_at_bnl.gov> writes:
>
>
>> Using the same versions as was used to produce the file lets me
>> to a TTree::Scan() and it looks like the majority of the data is
>> recoverable!
>>
>
> Sorry, I spoke too soon.
>
> While I can recover the file "live" just after I open it when using the
> same code versions, I can not "save" this recovery by opening the file
> with "UPDATE" as indicated by TFile::Recover() documentation. Also, if
> I do an explicit call to Recover() on the file after it is opened with
> "UPDATE" I can not access the contents even in the immediate session.
>
> If worse comes to worse, I can write code to manually copy the contents
> into a new file but maybe there is a way this should "just work"?
>
> The following four sessions show the cases for with and without using
> the "UPDATE" option and with and without an implicit call to Recover().
>
>
> Implicit Recover(), no UPDATE works, but file is unmodified:
>
> ----------------------------------------------------------------------
> shell> loon
> loon [0] TFile* f = new TFile("B100112_080001.mbeam.tofix.root")
> loon [1] TTree* t = (TTree*)f->FindObjectAny("BeamMon")
> loon [2] t->Scan()
> ...
> ----------------------------------------------------------------------
>
> Explicit Recover(), no UPDATE works, but file is unmodified:
>
> ----------------------------------------------------------------------
> shell> loon
> loon [0] TFile* f = new TFile("B100112_080001.mbeam.tofix.root")
> loon [1] f->Recover()
> Info in <TFile::Recover>: B100112_080001.mbeam.tofix.root, recovered key TTree:BeamMon at address 167327993
> (Int_t)(1)
> loon [2] TTree* t = (TTree*)f->FindObjectAny("BeamMon")
> loon [3] t->Scan()
> ...
> ----------------------------------------------------------------------
>
> Implicit Recover, with UPDATE works, but file is unmodified:
>
> ----------------------------------------------------------------------
> shell> loon
> loon [0] TFile* f = new TFile("B100112_080001.mbeam.tofix.root","UPDATE")
> Warning in <TFile::Init>: file B100112_080001.mbeam.tofix.root probably not closed, cannot read free segments
> loon [1] TTree* t = (TTree*)f->FindObjectAny("BeamMon")
> loon [2] t->Scan()
> ...
> loon [3] f->Close()
> loon [4] delete f
>
> shell> md5sum B100112_080001.mbeam.{original,tofix}.root
> 27ea3c7e18d287eaaec13bd2357a924d B100112_080001.mbeam.original.root
> 27ea3c7e18d287eaaec13bd2357a924d B100112_080001.mbeam.tofix.root
> ----------------------------------------------------------------------
>
> Explicit Recover with UPDATE will update the file but the file becomes
> usable both immediately and if saved and (re)opened in a new session.
>
> ----------------------------------------------------------------------
> shell> loon
> loon [0] TFile* f = new TFile("B100112_080001.mbeam.tofix.root","UPDATE")
> Warning in <TFile::Init>: file B100112_080001.mbeam.tofix.root probably not closed, cannot read free segments
> loon [1] f->Recover()
> Info in <TFile::Recover>: B100112_080001.mbeam.tofix.root, recovered key TTree:BeamMon at address 167327993
> (Int_t)(1)
> loon [2] TTree* t = (TTree*)f->FindObjectAny("BeamMon")
> R__unzip: error in header
> loon [3] t->Scan()
> Error: illegal pointer to class object t 0x0 326 (tmpfile):1:
> *** Interpreter error recovered ***
> loon [4] f->Close()
> loon [5] delete f
>
> shell> md5sum B100112_080001.mbeam.{original,tofix}.root
> 27ea3c7e18d287eaaec13bd2357a924d B100112_080001.mbeam.original.root
> bbf601f6855c0f845b9fb36dd9fa3e08 B100112_080001.mbeam.tofix.root
>
> shell> loon
> loon [0] TFile* f = new TFile("B100112_080001.mbeam.tofix.root")
> loon [1] TTree* t = (TTree*)f->FindObjectAny("BeamMon")
> R__unzip: error in header
> loon [2] t->Scan()
> Error: illegal pointer to class object t 0x0 326 (tmpfile):1:
> ----------------------------------------------------------------------
>
>
> -Brett.
>
>
>
>
Received on Fri Jan 22 2010 - 19:40:11 CET

This archive was generated by hypermail 2.2.0 : Fri Jan 22 2010 - 23:50:01 CET