In my SEC rule set, I am using an SQLite in-memory database to cache
data. When I shutdown SEC, I save this sqlite database to disk and
reload it into memory when SEC starts.

I've now observed several times, and it seems to be when the database is
large, that the save to disk procedure during SEC_SHUTDOWN doesn't
complete. In fact, I try to log messages so I have an idea of success or
failure of the $dbh->sqlite_backup_to_file() call; and I sometimes get
neither success nor failure log messages; SEC just shuts down. Here is
the log when this happens:

Wed Oct 21 15:00:50 2015: SIGTERM received: shutting down SEC

This is what I expect, and when it works normally:

Tue Oct 20 22:28:24 2015: SIGTERM received: shutting down SEC
Tue Oct 20 22:28:26 2015: INFO: database saved to disk on attempt 1.
Tue Oct 20 22:28:26 2015: INFO: database disconnect successful.

This is my rule during SEC_SHUTDOWN:

# save database to disk
type=Single
ptype=SubStr
pattern=SEC_SHUTDOWN
context=[SEC_INTERNAL_EVENT]
continue=TakeNext
desc=Save database to disk
action= lcall %ret -> ( sub{ \
            my $db_backup = '/var/lib/sec/cache.sqlite3'; \
            my $tries = 0; \
            my $ret; \
            my $msg; \
            my @return; \
            do{ \
                $ret = $dbh->sqlite_backup_to_file($db_backup); \
                $tries++; \
            } until ( $ret && ($tries <= 5) ); \
            push(@return,$ret); \
            if( $ret == 1 ){ \
                $msg = "database saved to disk on attempt $tries."; \
            } else { \
                $msg = $DBI::errstr; \
            } \
            push(@return,$msg); \
            return @return; \
        } ); \
        lcall %is_success %ret -> ( sub{ \
            my ($rc, $msg) = split(/\n/,$_[0]); \
            return $rc; \
        } ); \
        lcall %msg %ret -> ( sub{ \
            my ($rc, $msg) = split(/\n/,$_[0]); \
            return $msg; \
        } ); \
        if %is_success ( logonly INFO: %msg ) \
        else ( logonly CRIT: database failed to save to disk ); \
        lcall %ret -> ( sub{ \
            my $ret = $dbh->disconnect(); \
            return $ret; \
        } ); \
        if %ret ( logonly INFO: database disconnect successful. ) \
        else ( logonly CRIT: database disconnect failed. )

As you can see above, either success or failure should log a message,
but when this problem occurs, I get nothing. So, I'm wondering if during
SEC shutdown, is there a time limit on how long the shutdown procedure
has before it just exits completely? I wonder if when the database is
large, that the save to disk procedure takes too long and SEC just
exists without allowing it to complete? Is this possible?

Thanks
Bond


------------------------------------------------------------------------------
_______________________________________________
Simple-evcorr-users mailing list
Simple-evcorr-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users

Reply via email to