Subject rdb$get_context('SYSTEM', 'CLIENT_ADDRESS') sometimes returns NULL
Author Geoff Worboys
Hi,

Firebird v2.5.6 32bit "Classic"
on Windows 64bit 2012 R2 Standard

I have an ON CONNECT database trigger in which I try to collect
the client address and network protocol using:

rdb$get_context('SYSTEM', 'CLIENT_ADDRESS')
and rdb$get_context('SYSTEM', 'NETWORK_PROTOCOL')

Most of the time they work, but sometimes they return NULL.
For the same user they may return NULL in one call and then
return a valid string just a second later in another connection
for the same client.

I am not sure when this behaviour started, because it only
occurs in something like 1-in-20 (at a guess) connections I
had not noticed until recently.

The client is multi-threaded, but each thread has its own
connection instance etc. However it could be thread related
because:
Background-Thread connects to Database1
Background-Thread connects to Database2 then disconnects
(Foreground-Thread waits for the above and then)
Foreground-Thread connects to Database1
Foreground-Thread connects to Database2

As far as I can tell the NULL returns happen during the
Foreground-Thread connection to database1. (Not completely
certain of this is the only time, but it seems to happen that
way most of the time.)

This version of the client (this configuration of the threads)
has been running in production for around 6 months without any
obvious problems.


Anyone have ideas as to what causes this, and/or what I might
try to debug the issue?

--
Geoff Worboys
Telesis Computing Pty Ltd