Preprocessing happens before the decision on which AO profiles match.
So if your preprocessing script returns nil on the db2 alerts you don't want, then the alarm will be thrown away before the AO profile rules are evaluated. And since the alarm won't be there, your AO will not fire.
You also don't indicate how you are set up to fire the AO (on arrival, overdue age, etc) and this will make a difference on the behavior of the script and underlying alarms.
Your AO profile executes the line "a.assigned_to = "db2_alarm_logger"" which will have no effect. It will update the in memory copy of the alarm the AO is accessing but not the one saved.
And your call to action.close() will put this alarm update message back on the queue of alarms to process so if this is an on arrival AO and isn't filtering on alarm severity then it will also fire on the close event.
And you really should check return codes on everything. alarm.get() can return nil for instance which would cause future usages of the variable a to fault.
And find the nas technical reference document - the last couple pages of that will be a huge help.