While it doesn't maintain the same backend data format, if you want a single file solution you might look into DBD::SQLite instead and let the SQLite library handle these issues for you (see here for details and caveats).
The cake is a lie.
The cake is a lie.
The cake is a lie.
| [reply] |
Thanks for your response.
I have had SQLite recommended by others as an option for the backend. Actual database capabilities of the app are fairly light, so this may actually be a better option than mySQL, which was also being considered.
| [reply] |
I believe you are actually talking about DBD::CSV?
The documentation says it should work, if your system supports flock - which leads us to the question what your system is.
That aside I think in the long term you might be more happy with a "real" DB system, of course depending on your particular application. | [reply] |
Thanks for your response.
DBD::CSV? probably. My code just has "use DBI;"
Current system is Linux FC3 and will be migrated to latest CentOS in the near future.
I've determined that flock() is not reliable on this system. All files in question are accessed only from library routines, and switching from direct Perl functions to read, to the DBI, definitely made a difference.
As you suggest, moving to a real DB may be required. It was being considered for some time.
| [reply] |
| [reply] |
Thanks for your response.
The link is useful, and will provide more information to consider, especially for other projects. In particular, if we move from the DBI to accessing the files directly, there will be some more research and testing.
Because we were looking at migrating the app to multiple servers and NFS, the daemon I wrote SHOULD HAVE worked as a networkable file access arbitrator, running on the NFS server. As I understand it, this is the way the Open Distributed Lock Manger is supposed to do it (reference "Linux Enterprise Cluster" by Karl Kopper). However, the most recent I can find on it is 2004 or 2006 on sourceforge.
I've seen such conflicting information on flock(), though, and have a hard time bringing myself to trust it. Maybe a real DB is my only solution.
| [reply] |
Don't trust flock. It only works if your file is on the same physical system as your code. Even then, it doesn't always work. Furthermore, flock is only advisory. The OS doesn't enforce a flock to all processes.
Frankly, all flock does is put a flag on the file. If another process actually bothers to check the flag, the OS will let it know what the state is. If the other process just goes ahead and opens the file anyway, the OS will let it.
My criteria for good software:
- Does it work?
- Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
| [reply] |