Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DBF tables in Foxpo could get corrupt when reindex? (Without outage or crash)

We have a Foxpro exe application that is shared in a server and about 20 users run it. One colleague told me that if those dbf tables need to be reindexed, he should tell everybody to leave the exe application. If reindex process starts and some user is still running that application, then dbf tables will get corrupted.

That was intriguing me. Is that possible? Always thought that when reindexing a Foxprox DBF table, the process itself open table in exclusive mode and if table is already open in shared mode, it just did nothing to that table. Similar with PAK.

like image 894
Jorge Avatar asked Dec 20 '22 14:12

Jorge


1 Answers

While I agree that FoxPro tables can get corrupt, it is impossible from the situation you described. To reindex, you must have exclusive use of the table. Either you get a file lock or you don't:

  1. If someone is in the application and has a table open, then your reindex routine will either fail or it will not be able to reindex the files that are open. Your notion about doing "nothing to that table" is true if the programming to reindex tables handles errors when trying to lock tables that are already open.
  2. If your reindex routine is running and someone happens to be in the application or tries to run the application, they will most likely get errors and/or crash the app because they will not be able to open the tables (in shared mode).

Here is a list of most likely culprits of table corruption. There is mention of file locking problems, but that has to do with tables that include memo fields. These tables actually consist of 2 files (the DBF [table] and the FPT [memo]). I've had apps run for years without any corruption whatsoever.

like image 120
Ed Pecyna Avatar answered Dec 25 '22 22:12

Ed Pecyna