flightaware / speedtables

Speed tables is a high-performance memory-resident database. The speed table compiler reads a table definition and generates a set of C access routines to create, manipulate and search tables containing millions of rows. Currently oriented towards Tcl.
https://flightaware.github.io/speedtables/
BSD 3-Clause "New" or "Revised" License
66 stars 15 forks source link

Do not panic when shared-memory is full, raise Tcl error instead #8

Open bovine opened 13 years ago

bovine commented 13 years ago

When shared-memory becomes full and a new record is added, then the code currently calls the xxx_shmpanic() handler, which invokes panic() and aborts the process.

The code should be changed to raise a Tcl error that the user can "catch" and handle appropriately, perhaps by deleting some rows from the table.

bovine commented 13 years ago

There appears to be an undocumented "panic" option that can be specified to the "create" method (which sets ctable->share_panic), however it does not seem to be honored in all of the places it should be. Repeatedly calling "store" will still trigger a panic.

resuna commented 13 years ago

This is another hard problem we ran into during development.

The problem is that Speedtables memory management is based on Tcl's memory management, and Tcl assumes that memory allocations always succeed. Shared memory allocations can occur in places where there's no framework in Speedtables itself for propogating a failure back to a place where it can be handled.

bovine commented 13 years ago

Actually, it looks the argument parsing for the "panic" option was just bad. It was misinterpreting the return value from strcmp(). I committed a change to fix that obvious error, which allows me to now catch the failure during "store".

[master fc7589d] properly parse the "panic" option to "create". github issue 8. 3 files changed, 6 insertions(+), 1 deletions(-)

Leaving this issue open for now....