I recently added a new table called "inventory_trans" to my organization's database as part of an inventory tracking system. Whenever a user action elsewhere in the database creates a change in the current stock level, a record denoting the amount of change is entered in this table, which automatically posts to another table that contains the running total for each item we are tracking. All normal data entry to this table is done via Xbasic; only rarely will anyone enter a record directly.
I had this system up and running for about three weeks without a hint of trouble. The table grew to about 4300 records, no problem. Then one day I made a few changes at once: 1) I added a new posting field rule. 2) I added two filtered indexes to the table to accommodate the new rule. The system also automatically added a new index that was unfiltered with "recno()" as the order expression. 3) I ran a script which added over 17,000 records to the table, bringing the total up to more than 21,000 records. Instantly, I began getting EXTREMELY frequent messages saying that the indexes on this table had been corrupted. When I say extremely frequent, I mean that I was lucky to get 5 records entered before the message would show up again, even when entering manually into the default browse.
I suspected the new field rules, so I reverted to the old ones. No help. I read enough on this forum to think that the filtered indexes were the problem, so I deleted them. Still no help. I thought maybe it was a shadowing problem, since my development copy worked fine, but it was direct. No help there, and I shadowed my dev copy and it still worked fine. I checked over all the Xbasic that modified the table, & couldn't find any logical errors. I threw in a few "wait-for-idle" commands between the record entries just in case I was entering new records too quickly, but still no help. I deleted and rebuilt the indexes. Still no help.
Then I realized that my dev copy had significantly fewer records than my live copy. I copied the live data to the dev copy, and it instantly broke as well. So, now what? Back to the forums...after hours of searching I found a tiny little mention deep in one thread that someone else had consistent trouble with one table's indexes until he converted all the indexed fields to uppercase. I thought that was a bit far-out, but I tried it anyway. Presto! Everything works.
So my question is, WHY does my table exhibit this behavior? Is there some documented reason why the index keys need to be uppercase? How will I know if circumstances are right for this issue to crop up in the future? It seems to me that it's a flaw in the indexing algorithm, but maybe I'm missing something.
Here's the specifics on the table:
TABLE NAME:
Inventory_trans
FIELDS:
Item_ID (C, 8)
Date (D, 8)
Trans_Qty (N, 6.0)
Trans_Type (C, 1)
INDEXES:
Item_ID (Filter: none. Order: Item_ID, Ascending, All)
Itembydate (Filter: none. Order: Item_ID+cdate(DATE), Ascending, ALL)
Recno (Filter: none. Order: recno(), Ascending, All)
The indexes I deleted were:
Verified (Filter: TRANS_TYPE="V" Order: Item_ID+cdate(DATE), Ascending, All)
Unknown (Filter: TRANS_TYPE="U" Order: Item_ID+cdate(DATE), Ascending, All)
Item_ID may contain a number string (such as "1845"), mixed letters and numbers (such as "CD1845"), all letters (such as "CDSLVBLK"), letters & hyphens (such as "CD-R-VAL"), or letters, numbers, and hyphens (such as "2CD-CRYS"). This was the field I converted to uppercase in order to make the indexes work.
Any clues? Thanks in advance...
~Jason
I had this system up and running for about three weeks without a hint of trouble. The table grew to about 4300 records, no problem. Then one day I made a few changes at once: 1) I added a new posting field rule. 2) I added two filtered indexes to the table to accommodate the new rule. The system also automatically added a new index that was unfiltered with "recno()" as the order expression. 3) I ran a script which added over 17,000 records to the table, bringing the total up to more than 21,000 records. Instantly, I began getting EXTREMELY frequent messages saying that the indexes on this table had been corrupted. When I say extremely frequent, I mean that I was lucky to get 5 records entered before the message would show up again, even when entering manually into the default browse.
I suspected the new field rules, so I reverted to the old ones. No help. I read enough on this forum to think that the filtered indexes were the problem, so I deleted them. Still no help. I thought maybe it was a shadowing problem, since my development copy worked fine, but it was direct. No help there, and I shadowed my dev copy and it still worked fine. I checked over all the Xbasic that modified the table, & couldn't find any logical errors. I threw in a few "wait-for-idle" commands between the record entries just in case I was entering new records too quickly, but still no help. I deleted and rebuilt the indexes. Still no help.
Then I realized that my dev copy had significantly fewer records than my live copy. I copied the live data to the dev copy, and it instantly broke as well. So, now what? Back to the forums...after hours of searching I found a tiny little mention deep in one thread that someone else had consistent trouble with one table's indexes until he converted all the indexed fields to uppercase. I thought that was a bit far-out, but I tried it anyway. Presto! Everything works.
So my question is, WHY does my table exhibit this behavior? Is there some documented reason why the index keys need to be uppercase? How will I know if circumstances are right for this issue to crop up in the future? It seems to me that it's a flaw in the indexing algorithm, but maybe I'm missing something.
Here's the specifics on the table:
TABLE NAME:
Inventory_trans
FIELDS:
Item_ID (C, 8)
Date (D, 8)
Trans_Qty (N, 6.0)
Trans_Type (C, 1)
INDEXES:
Item_ID (Filter: none. Order: Item_ID, Ascending, All)
Itembydate (Filter: none. Order: Item_ID+cdate(DATE), Ascending, ALL)
Recno (Filter: none. Order: recno(), Ascending, All)
The indexes I deleted were:
Verified (Filter: TRANS_TYPE="V" Order: Item_ID+cdate(DATE), Ascending, All)
Unknown (Filter: TRANS_TYPE="U" Order: Item_ID+cdate(DATE), Ascending, All)
Item_ID may contain a number string (such as "1845"), mixed letters and numbers (such as "CD1845"), all letters (such as "CDSLVBLK"), letters & hyphens (such as "CD-R-VAL"), or letters, numbers, and hyphens (such as "2CD-CRYS"). This was the field I converted to uppercase in order to make the indexes work.
Any clues? Thanks in advance...
~Jason
Comment