I am using lighttpd with two procs and occasionally the .lock file
will not be properly removed by Ferret at which point my application
will end up throwing nothing but 500 errors.
Therefore, I have decided to go with a single writer thread… which
is probably a better long term solution anyways.
I would like some feedback on the best way to structure this. My app
is hosted on TextDrive, so drb (distributed ruby) is not allowed.
The only other solution I can come up with is to write all pending
updates to a shared file. This could involve either:
serialize each object using something like YAML to a file and then
deserializing them by the writer during updates.
just write the ids that need to be updated in the index and then
read each object fresh from the database using its id when updating
I am leaning towards solution 2, as it is easier to implement, should
be faster to write and read from the intermediate file and will be
easier to remove duplicate index updates. The only drawback to 2 is
it will require one additional database read for every index update…
but this could be minimized by batch reading with a where id in (…).
Also, both 1 and 2 will require a lockfile for managing concurrent
access to the intermediate file. I am thinking of just using this
lockfile library: http://raa.ruby-lang.org/project/lockfile/
Does anyone have any experience with this?