Infrastructure

Client Timezone Awareness

Previously, adjusting the time zone in which a database session operates could not be done in any way except globally, directly within the database. However, allowing modification of the timezone parameter now supports localization efforts for those consortia that span multiple time zones.

Implementation

CStore and other services that interact with the primary Evergreen database make use of the functionality provided by LP#1485371 in OpenSRF in order to set the time zone configuration parameter available in PostgreSQL.  This has the effect of interpreting all timestamps written to or read from the database in the client’s time zone.

Within CStore (and related, C-based services), all stateful sessions make use of this capability, setting the database time zone upon a successful CONNECT message from the client.  The time zone is reset to the database default when a session is terminated either due to client DISCONNECT or server keepalive timeout.

All stateless requests record the current database time zone, set the database time zone to that of the client’s, run the query, and then reset the database time zone on each request that carries a client time zone value.  It is expected that this will not cause any noticeable increase in latency or query execution time, as this setting is local to the specific PostgreSQL server backend process.

Within the Storage service, the timezone will be set automatically by a simple wrapper method used by the existing method registration mechanism for method publishing.  Disconnect and error callbacks are registered to revert the time zone setting within the database.  This provides completely transparent time zone manipulation for backend services that make use of open-ils.storage.