Ticket #197 (closed defect: fixed)

Opened 8 weeks ago

Last modified 8 weeks ago

Indexes behaves incorrectly when updated after a query

Reported by: faltet Owned by: somebody
Priority: major Component: PyTables Pro
Version: Keywords:
Cc:

Description

The next script shows the bad behavior:

from tables import *

small_blocksizes = (16, 8, 4, 2)
file_ = "/tmp/bug.h5"

class TDescr(IsDescription):
    var2 = BoolCol()

fileh = openFile(file_, "w")
table = fileh.createTable(fileh.root, 'table', TDescr, "")
table.cols.var2.createIndex(_blocksizes = small_blocksizes)
# Add some rows
for i in range(3):
    table.row.append()
table.flush()

# Do a query that uses indexes
res = [row.nrow for row in table.where('var2 == True')]
# Now, append one single row more
table.append([(True,)])

# Do a query that uses indexes
resq = [row.nrow for row in table.where('var2 == True')]
res_ = res + [table.nrows-1]
print "res_, resq:", res_, resq
assert res_ == resq

fileh.close()

which gives the next error:

HDF5-DIAG: Error detected in HDF5 library version: 1.6.7 thread 140117778474736.  Back trace follows.
  #000: H5Dio.c line 580 in H5Dread(): selection+offset not within extent
    major(14): Dataspace interface
    minor(04): Out of range
Exception tables.exceptions.HDF5ExtError: HDF5ExtError('Problems reading the array data.',) in 'tables.indexesExtension.IndexArray._g_readSortedSlice' ignored
res_, resq: [3] []
Traceback (most recent call last):
  File "bug.py", line 32, in <module>
    assert res_ == resq
AssertionError
Closing remaining open files: /tmp/bug.h5...HDF5-DIAG: Error detected in HDF5 library version: 1.6.7 thread 140117778474736.  Back trace follows.
  #000: H5D.c line 1224 in H5Dclose(): not a dataset
    major(01): Function arguments
    minor(03): Inappropriate type
  #001: H5I.c line 1257 in H5I_find_id(): invalid ID
    major(07): Atom layer
    minor(32): Unable to find atom information (already closed?)
 done

Change History

Changed 8 weeks ago by faltet

  • status changed from new to closed
  • resolution set to fixed

The space_id of datasets cannot be cached during index queries. This is because when the index is updated, this cache becomes unsynchronized.

So, the cache has been removed in r3901 (pro-trunk) and r3902 (sync in std-trunk).

Note: See TracTickets for help on using tickets.