Jason
Recent Actions
-
Commented on Suprisingly hard task of writing logs
Are log lines fixed length or variable length? You mentioned in one post your writing 'Storable' images?...
-
Commented on Suprisingly hard task of writing logs
I seem to have glazed over that part you wrote about locking both times :) You're right, multiple processes opening a file have no POSIX primitives to atomically modify it file. However, the vfs layer guarantees that rename() is atomic....
-
Commented on Suprisingly hard task of writing logs
Since it seems like this is all your code, can't you just use the 'advisory' locking flock() utilizes? The warning that it's merely advisory is moot here: if you control all the programs writing to this log file, you can...
-
Commented on Suprisingly hard task of writing logs
Multiple process writing to a single file without any kind of locking or single-threaded writer is a recipe for disaster. At first glance it looks dangerously easy to believe that write() or print() is atomic. As you are discovering, that...
-
Commented on What are your environment settings for Unicode?
Markus Kuhn has an excellent resource on UTF-8 On POSIX-like systems: http://www.cl.cam.ac.uk/~mgk25/unicode.html Included in that demo is http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-demo.txt Which is a handy file to have around to test if your terminal is configured for UTF-8, and/or what fonts you are...
Comment Threads
-
Vyacheslav Matyukhin commented on
Suprisingly hard task of writing logs
I'm not sure how *monitoring* system can help me in the task of implementing generic lightweight queues (log-based or not).
See also http://www.reddit.com/r/perl/comments/h4sm5/why_you_want_your_logging_system_to_not_rely_on/c1smyxd for the explanation why I'm trying to avoid DB-based solutions for this task. -
Vyacheslav Matyukhin commented on
Suprisingly hard task of writing logs
Hmm, I think you missed my point, or I didn't understand yours.
Your solution writes lines to the log without strict order.
You reserve portion of bytes in the file first, and then fill it in non-atomic way.
But a reader reads the file sequentially, and if it skips the line of zeroed bytes (or "\n"s, doesn't matter), then it will never read the data you write over these zeroed bytes later.
-
Salvador Fandiño commented on
Suprisingly hard task of writing logs
When the reader finds that some byte in the file is zero it should (busy) wait until it becomes non zero.
-
Vyacheslav Matyukhin commented on
Suprisingly hard task of writing logs
Busy wait is evil :)
And it won't work anyway. Write process can fail (possibly by sigkill) before it'll write non-zero data. -
Salvador Fandiño commented on
Suprisingly hard task of writing logs
Don't wait forever, just a little bit!
About blogs.perl.org
blogs.perl.org is a common blogging platform for the Perl community. Written in Perl with a graphic design donated by Six Apart, Ltd.