MiniM Database Server Start Sequence
This article describes steps executed by MiniM Database Server on start and can be useful to solve unpredictable problems in production and using together with other installed software.
Start of MiniM Database Server is a service start independently from what software call service to run. MiniM Database Server have additional utility MiniM Tray Icon, which present in the system tray. This utility allow to run, stop or restart server, but the same actions can be made by any other software what can to run or stop service and have enougt rights. Full service description see in special internal article in MiniM Advanced Guide. Moreover, MiniM service can be setting up to run automatically on computer start and in this case service will be run by internal Windows tools automatically.
On start service reads all settings from special initialization files minim.ini and minimdb.ini, determines need to be run or is this MiniM instance already run, calculates size and creates internal shared memory objects for this MiniM instance - caches for globals, routines, locks write queues and others. Shared memory objects are created with access rights need for access from all other MiniM processes and daemons independently from user accounts for read and write. Two or more different MiniM instances creates different shared memory objects with names derived from MiniM instance names, so several MiniM instances can work independently.
After shared memory objects creation server adjusts internal transaction sequence number. This counter is a synthetic and protected from date and time changes on the computer to prevent transaction collisions. Transaction sequence number adjust algorithm use current date and appropriate internal journal records. Much detailed description about this algorithm see in article How MiniM implements transaction sequence number.
At next step server runs database initialization process. In the case of any database are marked with AutoCreate option, this database recreates. With default MiniM installation this option have a "TEMP" database.
After end of database initialization server runs daemon guard threads: for write daemon to write database changed pages, for database expand daemon and for journal daemon to write journal records queue and special thread for performance counters to recalculate and adjust values for performance counters. Performance counters daemon still works and do all need actions self and other daemons runs appropriate daemon processes and waits his termination. Each daemon process makes apesial marks about his work in internal server data and in special files. In the case of one of daemon terminates with error by any reason, daemon guard thread runs this process again with special recovering option. And this process recovery internal data by need and continue execution transparently from any other server process.
At next step server determines need or not to run special thread from incoming telnet connections. In the case of server was setting up listen telnet connection, server run this thread using specified TCP/IP port. On next incoming connection to this port special MiniM process will be run to handle telnet connection with special option to serve TNT device and telnet thread still wait next incomint connection. All data interchange with telnet client is made by MiniM process.
Nest step server runs special internal incoming guardian thread. This thread waits special notofication messages from MiniM processes. Independently from tha way to run MiniM process each process notify guard subsystem about running. Guard incoming thread runs child guard thread for each MiniM process. Guard thread waits MiniM process termination and in the case of MiniM process terminates with any error by any reason, will run one more clearing process. Clearing process make complex doing in internal server structures to clear internal data from garbage, locks and cancel uncommitted data page changes. All other processes see terminated process as terminated normally by one step before error or abnormal termination. If this need, clearing process can rollback uncommitted transaction. All this are doing entirely transparently from any other MiniM process or daemon.
After write daemon, expand daemon, journal daemon and performance counters daemon was run, server can run any operations which can change databases. Now this steps include the following two:
Both this processes are run sequentially with waiting termination. After this processes server is entirely ready to use. Between rollback uncommitted transactions and autostart script execution server change state of the service to "Running" and service notify other Windows software about MiniM server is running. Autostart script execution is made after full server states are ready and is the first MiniM process to run.
If the server administrator was found any problems in server software working, he can determine any software dependencies of service run steps. For example, directly specify service is required TCT/IP software must be ready to use before MiniM service run, or any other software or Windows subsystems need to use from the autostart script.Eugene Karataev