drms_server [FLAGS] [SESSION_ARGUMENTS]
drms_server +----------------------------------------------+ | | +----------+ | +--------+ +--------+++ +-------------+ | | | | | +-+ in ||+--+ | | | SUMS +---+---+ SUMS | +--------+++ | +---+-------- client 0 | | | | thread | +++--------+ | | | | | | | +-+|| out +--+ +---+-------- client 1 +----------+ | +--------+ +++--------+ | | | | +--------+ | | | | | | | | | | | signal ----------------+ +---+-------- client n | | thread | | server | | | | | | thread pool | | | +--------+ +------++-----+ | +-----------------------------------++---------+ +------++-----+ | | | DB | | | +-------------+
The drms_server - Manages a database session and passes database requests to database from client modules is designed to support multiple client modules running at the same time. It performs the following major tasks:
drms_server - Manages a database session and passes database requests to database from client modules opens a single DB connection. This DB connection is shared by all modules connected to the same drms_server - Manages a database session and passes database requests to database from client modules program via sockets. Such shared DB connection makes drms_commit() issued from the client modules extremely hazardous, e.g., one client module can inadvadently commit another client module data. The correct usage of drms_commit requires higher level coordination among the client modules.
drms_server - Manages a database session and passes database requests to database from client modules talks the SUMS via SUMS API. All the interactions with SUMS are happenning in the SUMS thread, drms_sums_thread. This thread retrieves SUMS request from the sum_inbox, and places SUMS reply in sum_outbox. Both sum_inbox and sum_outbox are FIFO queues with the thread id as tag. They are shared memory. Don't insert local variable into the queue unless you are sure to get the reply back before the local variable vanishes. Due to FIFO queue implementation, only the head of the queue is examined. if the head is not removed, nothing behind it can be removed.
producer | consumer | |
sum_inbox | any call to SUMS API | drms_sums_thread |
sum_outbox | drms_sums_thread | function that needs SUMS call reply |
The closing sequence can be tricky, one might run into race condition if not careful. There are two exit routes: drms_server_commit() and drms_server_abort().
drms_delete_temporaries() removes all records created as DRMS_TRANSIENT drms_commit_all_units() commits all data units (does not include log SU) drms_server_close_session() { fflush() on stdout and stderr restore_stder() drms_commit() log SU update drms_session table entry } wait for SUMS threads to finish via pthread_join() disconnect stat db connection db_commit() for data db connection db_abort() for data db connection? drms_free_env()
db_rollback() on db data connection drms_server_close_session() add to sums inbox/outbox to thaw thread that may be waiting disconnect stat db connection db_abort() for data db connection sleep() to wait for other threads to finish cleanly. drms_free_env()
-h
: Show drms_server - Manages a database session and passes database requests to database from client modules usage information. -V
: Run drms_server - Manages a database session and passes database requests to database from client modules in verbose mode. -Q
: Run drms_server - Manages a database session and passes database requests to database from client modules in quiet mode. -f
: Run drms_server - Manages a database session and passes database requests to database from client modules in the foreground. Without -f
drms_server - Manages a database session and passes database requests to database from client modules spawns a server in a background process, prints the connection info to stdout and exits. -L
: Redirect stdout and stderr to SU log files. -n
: Turn off Nagle's algorithm on TCP/IP sockets. -s
: Set noshare which turns off the serializable mode for the database.param=value
, where param
is one of the following.JSOC_DBHOST
Specifies (overrides) the database host to connect to. Default is DBNAME JSOC_DBNAME
Specifies (overrides) the database name to use. Default is DBNAME JSOC_DBUSER
Specifies (overrides) the username used during database host connection. Default is USER. JSOC_DBPASSWD
Specifies (overrides) the password for the username. Default is PASSWD. JSOC_SESSIONNS
Specifies (overrides) the DRMS session namespace. DRMS_RETENTION
Sets (forces) the storage-unit retention time for all <modules> in the DRMS session. The environment is not searched for this keyword. DRMS_ARCHIVE
Sets (forces) the storage-unit archive flag for all <module>s in the DRMS session. The default is to let the client module or JSD prevail. Values are not given -> INT_MIN, or -1, 0, 1. The environment is not searched for this keyword. DRMS_QUERY_MEM
Sets the memory maximum for a database query. DRMS_SERVER_WAIT
Non-zero value indicates waiting 2 seconds before exiting, otherwise don't wait.