Hello,
MODX version : 0.9.5
This morning I tried to export my MODX database.
This was not easy since it grew to a size of 180 Mb (!!)
while it is a fairly small site I have.
Investigating the problem it became clear that the Event_Log
table has grown to almost 500000 (500 thousand!!) records.
While I do not check all 500000 records if there are any sensible
log entries, it leaves me with no other option that to truncate
the table.
What should be done is one of the following:
1) maximize the Event_Log table. Maximum number of records in
the config.
2) rotate the entries. If more than 1000 entries, remove the
100 oldest ones. (900 entries is also already too much to read,
but makes the table in the database easier to handle)
3) (Maybe nicest solution) Run an MD5 hash on your message,
if EventLogger wants to add a message, first check the md5 of
the message if it’s already there and keep a counter of the
number of same messages.
(The error which appeared 500000 times will be left in another
topic of course)
Thanks,
Bert Catsburg
My previous idea about automatically cleaning up the even_log after X records sounds nice, but the problem is that MODX CMS does not have any Batch Processing. So, what should trigger the cleaning up. We don’t want every Write action to the event log made slower because it has to do a SELECT COUNT(*) of the table.
I would suggest the following flow of the cleaning-up routine:
1) Have a System Parameter indicating how many records the Site Owner wants in the even log. Default to 1000.
2) Every time a record is written, increase a counter in another table.
3) Check the counter every time (probably this system setting is loaded in memory anyways, I don’t know the core of MODX to know this)
4) If counter reaches MAX + 10%, remove 20% of the records.
OR
1) Have a System Parameter indication how often the event log should be checked and cleaned. (in Number of Days)
2) Records the last time checking and cleaning was done.
3) If Current Time > (Last Time + number of days) --> Check and Clean.
Since I don’t know the core code of MODX, I have no clue where to look for the code which writes the Event Log. Probably in /manager/actions somewhere?
A cron is no option since most of our customers are running on Shared Hosting environments. There is no access to Cron in Shared Hosting.
I can imagine that most of the website built with MODX are running in Shared Hosting.
Speaking from Europe (Netherlands in fact) I can safely say that most medium sized business websites run on shared hosts. There might be a connection (XML, HTTP-Post, SOAP) connection to a backend ERP system or something, but the frontends are mostly running in shared hosts in the big datacenters in Amsterdam.
The ModRegistry sounds very interesting, but I hope it will be implemented in such a way that Shared Hosting websites can also benefit from this functionality.