Opened 16 years ago
Closed 15 years ago
#329 closed enhancement (fixed)
[PATCH] Store log messages in files rather than database rows
Reported by: | dfraser | Owned by: | dfraser |
---|---|---|---|
Priority: | major | Milestone: | 0.6 |
Component: | Build master | Version: | dev |
Keywords: | log storage | Cc: | cmlenz, thomas.moschny@… |
Operating System: |
Description
Storing log messages in the database is very expensive. We should switch to storing them in files
Attachments (2)
Change History (19)
comment:1 Changed 16 years ago by dfraser
- Status changed from new to assigned
comment:2 Changed 16 years ago by dfraser
comment:3 Changed 16 years ago by dfraser
I've now actually run the upgrade on two large systems (3.5GB and 1.1GB sqlite database due to all the log messages). With the current code:
- If anything goes wrong in the log file migration, the bitten_log table ends up empty. I could fix this with a db.commit() at the end of the filename column addition...
- The old bitten_log_message table is not dropped. After manually dropping this you need to run vacuum to shrink the database.
The levels are currently stored in a supplementary log file, although nothing is done with them - I thought it safer to preserve them at the moment.
This might need more testing before it gets committed to trunk - not sure whether that would be more effectively done in a branch or by persuading someone, or I should just go ahead and be brave, but I'd hate to lose people's log messages :-)
comment:4 follow-up: ↓ 6 Changed 16 years ago by thomas.moschny@…
- Cc thomas.moschny@… added
Does this patch work with the (experimental) 0.11 version of Bitten?
comment:5 Changed 16 years ago by anonymous
- Summary changed from Store log messages in files rather than database rows to [PATCH] Store log messages in files rather than database rows
comment:6 in reply to: ↑ 4 Changed 16 years ago by dfraser
Replying to thomas.moschny@…:
Does this patch work with the (experimental) 0.11 version of Bitten?
It does now after that update; this has of course become the trunk version now... sorry for slow reply
Changed 16 years ago by dfraser
Updated patch that applies to new trunk that was taken from 0.11 branch (and fixes silly error)
comment:7 follow-up: ↓ 8 Changed 16 years ago by ebray
Thanks for the patch. I haven't really run into this limitation myself yet, but I can imagine that on some projects it will become a problem. I'm also considering adding an extension to compress older log files.
One small problem I ran into is that in upgrades.py there should be something like:
if not os.path.isabs(logs_dir): logs_dir = os.path.join(env.path, logs_dir)
Otherwise it breaks unless I'm actually running trac-admin from my Trac environment directory, which I usually don't.
comment:8 in reply to: ↑ 7 ; follow-up: ↓ 9 Changed 16 years ago by dfraser
Replying to ebray:
Thanks for the patch. I haven't really run into this limitation myself yet, but I can imagine that on some projects it will become a problem. I'm also considering adding an extension to compress older log files.
Yes compressing log files should be easy with this.
One small problem I ran into is that in upgrades.py there should be something like:
if not os.path.isabs(logs_dir): logs_dir = os.path.join(env.path, logs_dir)Otherwise it breaks unless I'm actually running trac-admin from my Trac environment directory, which I usually don't.
Great thanks I'll add that to the patch. So I'm assuming otherwise it works for you...
Changed 16 years ago by dfraser
Enables storing log messages in files rather than database (adjusted to check abs path on upgrade)
comment:9 in reply to: ↑ 8 Changed 16 years ago by ebray
Replying to dfraser:
Great thanks I'll add that to the patch. So I'm assuming otherwise it works for you...
Yep, seems to work fine. The only other problem is that I had to manually give my web server user ownership of the log/bitten directory. Not sure how to better deal with that though.
comment:10 follow-up: ↓ 11 Changed 16 years ago by anonymous
Just applied this patch to my copy of Bitten. So far so good -- excellent work!
comment:11 in reply to: ↑ 10 Changed 16 years ago by dfraser
Replying to anonymous:
Just applied this patch to my copy of Bitten. So far so good -- excellent work!
OK, on the basis of the feedback so far I'm going to commit this - I've just added a message to say that people need to check permissions and look at dropping the table.
This is still svn so anyone using latest svn should be prepared to do a little bit of testing and all the feedback so far indicates this is working fine.
comment:12 Changed 16 years ago by dfraser
Applied in r590. Waiting for feedback from mailing list before marking this as fixed...
comment:13 Changed 16 years ago by dfraser
Fixes to tests in r591 to make them handle creating logs dirs
comment:14 follow-up: ↓ 15 Changed 16 years ago by felix.schwarz@…
Actually there is an error in trunk/bitten/upgrades.py?rev=591#L333 env.log_warning does not exist, this should be env.log.warning
comment:15 in reply to: ↑ 14 Changed 16 years ago by dfraser
Replying to felix.schwarz@…:
Actually there is an error in trunk/bitten/upgrades.py?rev=591#L333 env.log_warning does not exist, this should be env.log.warning
Woops, thanks! Fixed in r592
comment:16 Changed 16 years ago by dfraser
This looks like it's working to everyone's satisfaction now.
The remaining step is to make the upgrade automatically drop the table
comment:17 Changed 15 years ago by dfraser
- Resolution set to fixed
- Status changed from assigned to closed
Added the final step of dropping the bitten_log_message table in r693. Note that this will not drop tables of people who have already upgraded - but hey, they're the cutting-edge few who're running on trunk, so they should have taken care of it themselves.
IRC chat from today: