A better clean of MySQL sources

This forum covers ideas and discussions on future phpLogCon versions. Most importantly, all discussions on the upcoming version 2 should go here.

Google Ads


A better clean of MySQL sources

Postby brownw03 » Thu Aug 26, 2010 5:25 pm

When an admin chooses to completely erase the table, it would also be desirable to reset the auto_increment back to 1. The schema defines the ID as an unsigned int, so while it can hold over 4 billion values, it will be exceeded at some point and the UI should give a means to "reset" the system. I wrote a script to 1) drop the ID column, 2) truncate the table and 3) add the ID column and PK. This effectively resets the table to "1". Without dropping the column, rsyslog could stuff a new record in after the truncation, but before the auto_increment value is reset, which would prevent the auto_increment from ever being reset since MySQL looks at the current max value before setting it.

Since Rsyslog doesn't rely on ID at all, it's ability to insert records in the absence of the ID column is unaffected during this process. Adding the column back (and as a primary key) simply inserts new incremental IDs on any records that came in while the column was not present. Strictly speaking they may then appear in loganalyzer out of order, but this only affects the few records that come in while the column is not present. If the order must be guaranteed, then one last truncate would get it back in order, and numbering would simply continue from some very low value.
brownw03
New
 
Posts: 3
Joined: Thu Aug 26, 2010 3:33 pm

Urgent Question?

  • Pulling out your Hair?
  • Wasting Time and Money?
  • Deadline Approaching?

Google Ads


Return to Future Versions

Who is online

Users browsing this forum: No registered users and 0 guests

cron