• Problems with TH - and a fix

    By Doug Finner 1 decade ago

    I made the following changes to TH and set it up as described below.



    With help from Brandt Fundak extended the class to allow the audit records to be written to any log db, not just log.nsf.

    Each db to be audited gets a profile document of a given name. When TH executes during an edit operation, if the profile doc is not present, the code aborts.

    The profile doc allows me to set the log db to hold audit data for the db. If the pointer isn't set, when TH executes, it aborts.

    The TH agent lives in one db on the server.

    The Trigger in TriggerHappy.nsf has a single trigger that executes on all dbs on the server using the single agent in the TH Agent db. The Trigger is configured to skip system dbs and any db where access is depositor (via the 'and only when formula is true' field).



    Here's the flow of the code.

    User opens a doc, edits it, and saves.

    TH runs

    Profile doc present? No - abort

    Profile doc specifies log db? No - abort

    Open the log db

    Write changes

    Close the log db.



    For one doc at a time processes initiated by the user (ie the user edits/saves the doc), this works OK.



    I have any number of dbs where the user fills in a form and one to many Notes docs are created in a batch via a LS routine. For example, we want to create blank test records for a serialized item. The test record contains about 1900 Notes docs.

    The db design does not contain a profile doc so TH should quickly abort as these docs are created.

    The process is incredibly slow. With TH enabled (and keep in mind that this db isn't audited yet), I aborted the doc creation process after 10 minutes and only 400 docs had been created. When I disabled the Trigger and repeated the experiment, the process took just over 40 seconds for 1900 docs.



    I tried adding the condition !@IsNewDoc to the Trigger to see if the Trigger would abort more quickly, no joy.



    I've disabled the agent.



    Any ideas? If you need/want me to post code, I'll be happy to put up my mods.





    Per a suggestion in another thread, I loaded up Audit Manager and that seems to address all of the issues I've run into. I plan to roll out Audit Manager gradually so I can keep track of what impact it has on both server performance and the user's experience in a db.