Fix disk-space leak in StandardStMan and IncrementalStMan (#1566)
This fixes the issue reported by Reinout:
I think I’ve found a disk-space leak in casacore tables. Removing an array column that is not FixedShape from a StandardStMan or IncrementalStMan deletes the data manager and its table.fN file, but leaves the indirect-array file table.fNi on disk. Nothing refers to that file any more, so its space is never reclaimed. Fixed-shape columns don’t leak. I see this with casacore 3.8.2 and python-casacore 3.6.1.
Minimal reproducer:
import os, numpy as np
from casacore.tables import table, maketabdesc, makescacoldesc, makearrcoldesc
td = maketabdesc([makescacoldesc('KEEP', 0),
makearrcoldesc('ARR', 0j, shape=[16, 4], datamanagergroup='grp',
datamanagertype='StandardStMan')]) # not FixedShape -> indirect
t = table('leak.tab', td, nrow=10000, ack=False)
t.putcol('ARR', np.ones((10000, 16, 4), complex)); t.close()
t = table('leak.tab', readonly=False, ack=False)
t.removecols(['ARR'])
print(sorted(v['SEQNR'] for v in t.getdminfo().values())) # [0]: data manager 1 is gone
t.close()
print({f: os.path.getsize('leak.tab/' + f) for f in os.listdir('leak.tab') if f.startswith('table.f')})
In practice this hits pipelines that add and drop temporary model columns, for example per-direction MODEL_DATA columns in calibration. One of my MSs had 120 such orphan files totalling 6 TB(!). I now delete the leftover files myself after removecols, but it would be good to fix this in casacore.