betabug... Sascha Welter

home english | home deutsch | Site Map | Sascha | Kontakt | Pro | Weblog | Wiki

31 March 2017

fstail in ZODB

Just a little peep into the inner workings

Back in my Zope days, I once hunted for some writes to the ZODB being too big. I wrote a post called "Quasi-Normal in Numbers" about the experience. Back then I checked the size of the Data.fs file in the file system.

Nowadays I'm more into using Pyramid instead of Zope, I still use the ZODB (what can I say, it works well for me). And I still get sometimes the problem that a write puts in too many Bytes (or even kBytes) into the DB.

I've moved ahead though: Instead of checking the size of the database file on the file system, I discovered fstail. It's a little script that examines the end of the DB file and displays the last 10 transactions. (By default, actually you can use the parameter -n to get more). I didn't find any documentation of it, so I had to read the source and figur it out as good as I could.

So far I haven't solved today's problem, but I managed to solve a small sub-problem: I had some transactions that were committed by my code, and I couldn't identify them in the output. So today I learned to put some info onto that transaction:

url = getattr(request, 'url', 'no url')
note = "mymethod %s " % (url,)
transaction.get().note(note)
transaction.get().setUser(user, path='')
transaction.commit()

With this I can at least identify which of the transactions are caused by manually committing the transaction in my code at that spot.

Note: fstail comes with ZODB, so in my Pyramid virtualenv, it's already in the virtualenv's bin directory, ready to use: fstail -n 20 /path/to/Data.fs.


Posted by betabug at 20:30 | Comments (0) | Trackbacks (0)