Double-clicking a DB to start PanX fails to connect to server

With b7 installed, and the server running on the same computer, and PanX not running, PanX never connects a shared database to the server if I start PanX by double-clicking a database file. I receive a notification “Server Error Could not connect to [Server Name]”

But if PanX is already running, the database starts without a problem regardless of how it is started (clicking its icon or by a procedure).

In the first situation, it does not appear that the .Initialize procedure is ever reached; no console message comes from the it. It does apparently load custom statement, however. Also, it does not open auxiliary databases.

On my first attempt deal with this situation and understand how to recover, I put these two statements in my .Initialize procedure:

console "starting initialize in TGC Navigator"
connecttoserver

That resulted in an endless loop; it just repeated these steps over and over until I forced quit. That one I really don’t understand.

Then I removed the above code from .Initialize and put a text display object on the first form displayed and put this code in it:

if info("serverconnection")=0 
    connecttoserver
    call ".Initialize"
else
    nsnotify "server ok","sound","tink"
endif

(The TDO displays ‘Click Me First’ if the database is not connected to the server.)

That seems to be a reasonable work around. All the databases after the first one opened should be normal, I think.

Is this new behavior? Or did this also happen before?

Off the top of my head I don’t know why that would happen either, but Panorama is already performing the connecttoserver operation just before it calls the .Initialize code, so I’m not surprised that doesn’t work.

Ok, let’s put all this new instrumentation to work. Open the Instrumentation panel, enable the log.

  • Click on the star and choose Shared Database Open & Close (great, I immediately see a bug, it shows the checkmark on the wrong item, but the correct coverage is enabled).

  • Click on _DatabaseLib and then on the right click on INITIALIZEDATABASE.

  • Then click on the star again and choose Enable While Starting Up.

Now quit Panorama and relaunch by double clicking on a shared database. It may generate a huge log but it should have useful information.

I had another thought – I wonder if the database is opening faster than Bonjour can find the server? If so then I would expect that this is not a new problem.

If that is the problem then it might now show up with Instrumentation turned on, since Instrumentation has a significant performance impact.

Three tests:

I enabled the instrumentation, then started Navigator (a different file that connect to my office PanX server over the VPN. It started normally.

Second I started a database (Recipes) that connects to the server on my computer. It did not start properly; did not connect to the server and I don’t think the .Initialize procedure ran.

Third: this was exactly the problem I described this morning. PanX closed. Double-click TGC Navigator DB (connects to my server on my computer). Failed to connect to the server and .Initialize did not run.
I inserted a note here in the output file. At this point I clicked on the ‘Click Me First’ TDO that I described this morning. The balance of the output occurred after clicking the TDO: the DB connected to the server and .Initialize ran.
I am emailing the file, since the forum doesn’t accept .txt files.

Check to make sure I got my note in the right location. Here’s a repeat of starting TGC Navigator.

(Attachment Panorama X Instrumentation Log 2.txt is missing)

If you emailed the log separately, I didn’t get it. However, I was able to extract an attachment from the email. It’s not that long, so I’ve embedded it below so I can be sure we are talking about the same thing. Is this just test three? I don’t see anything about Recipes.

At the end, you say "CONNECTD TO SERVER AND RAN .INITILIZE UNTIL IT REACHED THE START TIMER; " Am I supposed to know what the start timer is? FYI, if you’re using a timer to run code one time, you can now do that easier with the executeasap statement. This statement creates the appropriate timer for you.

FYI, I think I know why using connecttoserver in .Initialize causes a loop – connecttoserver uses the same code used when opening the database so it calls .Initialize again! Voila – endless loop. I’ll fix that. But I’ll be clearing up the connection problem so that you won’t need this workaround or your extra text display button. I’m pretty sure the problem is that it takes a second or two for bonjour to locate the server. When Panorama first launches I’m going to have it delay reporting an error right away to allow extra time for the server to appear. Kind of like the old Bonjour Threshold but it will only be right when it first launches.
=================================================================================
====
==== START OF DEBUG LOG ==== Sat, August 1st, 2020 at 4:35 pm ====
==== VERSION: 10.2.0.b7 BUILD: 3410 (Client)
==== ROLE: Administrator
==== COMPUTER: Thomas’s Mac mini f0:18:98:eb:12:72
==== USER: Thomas Cooper
====
==== DEBUG LOG COVERAGE =========================================================
_EnterpriseClientLib=CLIENTCLOSESHAREDDATABASE,CLIENTLOGOFF,CLIENTLOGON,CLIENTOPENSHAREDDATABASE&_EnterpriseServerLib=_serverCLOSESHAREDDATABASE,_serverLOGOFF,_serverLOGON,_serverOPENSHAREDDATABASE&_DatabaseLib=INITIALIZEDATABASE
=================================================================================

CLIENT OPEN DATABASE ==================================================
[CLIENTOPENSHAREDDATABASE] targetDatabase: TGC Navigator
[CLIENTOPENSHAREDDATABASE] Start connection.
[CLIENTOPENSHAREDDATABASE] Client logon.
CLIENT LOGON ==================================================
[CLIENTLOGON] realURL: TGC PanX Server
[CLIENTLOGON] Existing sessionID: 
[CLIENTLOGON] Logon to TGC PanX Server
[CLIENTLOGON] === DICTIONARY xreply ============
[CLIENTLOGON] STATUS="ERROR"
[CLIENTLOGON] INFO="ERROR: No available server named TGC PanX Server"
[CLIENTLOGON] === END OF DICTIONARY xreply ============
[CLIENTOPENSHAREDDATABASE] Connect Error: ERROR: No available server named TGC PanX Server

[TGC NOTE:  STOPPED HERE;  DID NOT CONNECT TO THE SERVER AND DID NOT RUN .INITIALIZE.  NOW GOING TO CLICK 'CLICK ME FIRST.]

[TIME: 4:36 PM]
CLIENT OPEN DATABASE ==================================================
[CLIENTOPENSHAREDDATABASE] targetDatabase: TGC Navigator
[CLIENTOPENSHAREDDATABASE] Start connection.
[CLIENTOPENSHAREDDATABASE] Client logon.
CLIENT LOGON ==================================================
[CLIENTLOGON] realURL: TGC PanX Server
[CLIENTLOGON] Existing sessionID: 
[CLIENTLOGON] Logon to TGC PanX Server
[CLIENTLOGON] === DICTIONARY xreply ============
[CLIENTLOGON] STATUS="OK"
[CLIENTLOGON] SESSIONID="30"
[CLIENTLOGON] LOOPBACK=""
[CLIENTLOGON] === END OF DICTIONARY xreply ============
[CLIENTLOGON] === DICTIONARY openSessions ============
[CLIENTLOGON] TGC PanX Server="30"
[CLIENTLOGON] === END OF DICTIONARY openSessions ============
[CLIENTLOGON] === DICTIONARY _EnterpriseURLs ============
[CLIENTLOGON] TGC PanX Server="30"
[CLIENTLOGON] === END OF DICTIONARY _EnterpriseURLs ============
[CLIENTLOGON] Logon complete. sessionID: 30
[CLIENTOPENSHAREDDATABASE] hostServer: TGC PanX Server
[CLIENTOPENSHAREDDATABASE] hostDatabaseName: TGC Navigator
[CLIENTOPENSHAREDDATABASE] hostDatabaseID: 1A8C46AF-2481-4862-BFC5-CB68D783AC2E-2610-000017C0457DB4BE+3677004028
[CLIENTOPENSHAREDDATABASE] sessionID: 30
[CLIENTOPENSHAREDDATABASE] === DICTIONARY xreply ============
[CLIENTOPENSHAREDDATABASE] STATUS="OK"
[CLIENTOPENSHAREDDATABASE] LOOPBACK=""
[CLIENTOPENSHAREDDATABASE] === END OF DICTIONARY xreply ============
[CLIENTOPENSHAREDDATABASE] Connected - sessionFiles: TGC Navigator
[INITIALIZEDATABASE] ===== Start .Initialize procedure (TGC Navigator) =====
[INITIALIZEDATABASE] ===== End .Initialize procedure (TGC Navigator) =====
[INITIALIZEDATABASE] resume after database timer task: TGC Navigator

[TGC NOTE:  CONNECTD TO SERVER AND RAN .INITILIZE UNTIL IT REACHED THE START TIMER;  AN ERROR DIALOG SAID THE TIMER WAS A
DUPLICATE;  SURPRISING SINCE THE TIMER NAME CAME FROM A SUPERNOW() FUNCTION.]

In spite of the email problems, it looks like the instrumentation log helped solve the first problem that came up.
Thanks for the tip about executeasap. I don’t think I have a good understanding of when it is useful, but I am going to read the material again and try to understand when it is needed.
Regarding the start timer, I did not know what you can glean from the log and mentioned the there was a start time in the .Initialize procedure that failed to execute properly. Not the main issue we are discussing, but maybe another one down the road.
The documentation, on Run Loop in particular, there are discussions of situations where certain code will not work properly, such as implicitly triggered procedures. That is a completely new idea to me and I probably need to review databases to see if that has happened and could be causing problems.

If you look at the code for executeasap you’ll see that it is simply is a way to start a timer that runs once as soon as possible. You could do the same thing with the starttimer statement but executeasap just makes it a lot simpler.

let code = parameter(1)
starttimer "asap_"+info("guid"),
    "code",code,
    "repeat",1,
    "next",supernow(),
    "scope","global",
    "password","nobigsecret"

There should not be any reason why a start timer would not work when triggered in an .Initialize procedure.