Bug hunting: Deadlocks, data safety, and dumb shit
authorChip Black <bytex64@bytex64.net>
Sat, 1 Jun 2013 08:02:51 +0000 (03:02 -0500)
committerChip Black <bytex64@bytex64.net>
Sat, 1 Jun 2013 08:17:33 +0000 (03:17 -0500)
commit5b9a1c597b87485253a11339067b60d08534f8b0
tree355244879e418a2c12abaac612b845f9f9ee8255
parentd81158e4b60f0e0dff1e13adb253c2e01865de0d
Bug hunting: Deadlocks, data safety, and dumb shit

- Don't preallocate index files, instead just ftruncate() them to size.
  Index locality is pretty well moot when we're never reading more than
  50 entries at a time.
- Factor out data remapping
- Added extra bounds checks for segments and records
- Wasn't actually updating blerg->current_segment when switching
  segments, causing deadlock when the second record is written in a new
  segment.
- Use posix_fallocate() instead of writing zeroes
- Update record count *after* successfully writing a record, not before
- Use fstat to determine new record data offset instead of ftell (not
  sure if this is better, but it sure looks cleaner).
- Don't bother trying to write the rest of the data when we get a short
  write.  Truncate and move on.
database/database.c