Closed firebird-automations closed 3 years ago
Commented by: @hvlad
In your setup both Firebird "instances" share same shared memory area used by Trace Services to store its configuration. Audit session created only when shared memory is initialized, more precisely - when engine is loaded. In your case engine is loaded by first instance and creates no audit trace session in Trace configuration. Then first instance left idle with no connections. After few timeouts it unloaded engine and, if there is no other engine instances in other processes, it removes Trace Services configuration shared memory. If there is no existing Trace configuration when second instance loads engine - it creates new one and put audit session there.
This is all by design and only solution than could satisfy your needs (in presented form) - true implemenation of Firebird instances with correctly separated resources (and shared memery in particular).
Submitted by: @pavel-zotov
Weird behaviour was encountered during attempts to implement test for CORE5993. Steps to reproduce:
* create two folders for FB instances (in the commands list below these are: "C:\FB\40SS\" and "C:\FB\fb40-tmp\");
* put (unpack) entire FB distributive to each of these folders;
* open firebird.conf in each of them and set different ports for listening (e.g. 3400 and 57456 )
* STOP any running FB servers
* add to firebird.conf in the 2nd FB instance (which is in "C:\FB\fb40-tmp\") line for audit:
AuditTraceConfigFile = "C:\FBTESTING\qa\fbt-repo\tmp\tmp_c5993_audit.cfg"
* create config for audit (file "C:\FBTESTING\qa\fbt-repo\tmp\tmp_c5993_audit.cfg"):
database= { enabled = true log_filename = "C:\\FBTESTING\\qa\\fbt-repo\\tmp\\tmp_c5993_audit.log" time_threshold = 0 log_initfini = false log_warnings = false log_errors = true log_connections = true log_transactions = true log_statement_finish = true }
* Create batch with following content:
@echo off @setlocal enabledelayedexpansion enableextensions
@rem ######## set DELAY=130 @rem ########
set log=%\~dpn0.tmp
taskkill /f /t /im firebird.exe
tasklist | findstr /i /c:"firebird.exe" >nul if NOT errorlevel 1 ( echo At least one running FB instance detected. You have to stop all of them. goto :fin )
@echo on
start C:\FB\40SS\firebird.exe -a start C:\FB\fb40-tmp\firebird.exe -a
ping -n 2 127.0.0.1>nul
@echo !time! Call services API of the first FB instance. Check result: C:\FB\40SS\fbsvcmgr.exe localhost/3400:service_mgr user sysdba password masterkey info_user_dbpath
@echo Take delay for !delay! seconds. timeout !DELAY!
@echo !time! Check that active session exists in the TRACE list of the second FB instance: C:\FB\fb40-tmp\fbsvcmgr.exe localhost/57456:service_mgr user sysdba password masterkey action_trace_list 1>!log! @rem C:\FB\fb40-tmp\fbsvcmgr.exe localhost/57456:service_mgr user sysdba password masterkey info_user_dbpath 1>!log! @echo off
for /f %%a in ("!log!") do ( if %%\~za EQU 0 ( echo ####### ACHTUNG ####### echo NO TRACE SESSIONS FOUND echo ####################### ) else ( type !log! ) )
del !log! taskkill /f /t /im firebird.exe
:fin echo Bye-bye.
PAY ATTENTION on variable DELAY. Now it is 130.
Run this batch. Its output will be:
C:\FBTESTING\qa\misc>start C:\FB\40SS\firebird.exe -a
C:\FBTESTING\qa\misc>start C:\FB\fb40-tmp\firebird.exe -a
C:\FBTESTING\qa\misc>ping -n 2 127.0.0.1 1>nul 12:21:39.56 Call services API of the first FB instance. Check result:
C:\FBTESTING\qa\misc>C:\FB\40SS\fbsvcmgr.exe localhost/3400:service_mgr user sysdba password masterkey info_user_dbpath Security database: C:\FB\40SS\SECURITY4.FDB Take delay for 130 seconds.
C:\FBTESTING\qa\misc>timeout !DELAY!
Waiting for 0 seconds, press a key to continue ... 12:23:50.13 Check that active session exists in the TRACE list of the second FB instance:
C:\FBTESTING\qa\misc>C:\FB\fb40-tmp\fbsvcmgr.exe localhost/57456:service_mgr user sysdba password masterkey action_trace_list 1>!log!
Session ID: 1 name: Firebird Audit user: SYSDBA date: 2021-01-28 12:23:50 flags: active, admin, system, audit SUCCESS: The process with PID 2652 (child process of PID 2800) has been terminated. SUCCESS: The process with PID 6292 (child process of PID 2800) has been terminated. Bye-bye.
So far, so good: we can see audit session in the trace list.
Now change DELAY variable to 129.
Output will be finished like this:
###### ACHTUNG #######
NO TRACE SESSIONS FOUND
######################
SUCCESS: The process with PID 6780 (child process of PID 5952) has been terminated. SUCCESS: The process with PID 6932 (child process of PID 5952) has been terminated. Bye-bye.
PS. Checked on 4.0.0.2345 SS
Config file for 1st FB:
AuthClient = Srp, Srp256, ExtAuth, Win_Sspi, Legacy_Auth AuthServer = Srp, Srp256, ExtAuth, Win_Sspi, Legacy_Auth BugCheckAbort = 1 DefaultDbCachePages = 20000 ExtConnPoolLifeTime = 10 ExtConnPoolSize = 10 ExternalFileAccess = Full FileSystemCacheThreshold = 65536K IpcName = fb40_SS KeyHolderPlugin = KeyHolder LockHashSlots = 22111 LockMemSize = 5M MaxUnflushedWrites = -1 MaxUnflushedWriteTime = -1 ReadConsistency = 0 RemoteServicePort = 3400 ServerMode = Super TempBlockSize = 2M TempCacheLimit = 2147483647 TempDirectories = d:\temp UDFAccess = Restrict UDF UserManager = Srp, Legacy_UserManager WireCrypt = Enabled WireCryptPlugin = ChaCha, Arc4
Config file for 2nd FB:
AuditTraceConfigFile = "C:\FBTESTING\qa\fbt-repo\tmp\tmp_c5993_audit.cfg" AuthClient = Srp AuthServer = Srp BugcheckAbort = 1 IpcName = tmp_ipc_5993 RemoteServiceName = tmp_fbs_5993 RemoteServicePort = 57456 ServerMode = Super WireCrypt = Required