596fc9e27b7266b9692723e059731fa8ff2bbd11
hiram
  Fri Jun 12 11:24:40 2026 -0700
do not need the central db connection until after the captcha verification - this appears to eliminate all SQL connection for failed robot contacts

diff --git src/hg/lib/cart.c src/hg/lib/cart.c
index f3a741988e9..0bd6dd90b68 100644
--- src/hg/lib/cart.c
+++ src/hg/lib/cart.c
@@ -1661,52 +1661,52 @@
 cgiApoptosisSetup();
 
 setUdcCacheDir();
 
 netSetTimeoutErrorMsg("Connection timeout: either the server is offline or any firewall between UCSC and the server blocks the connection.");
 }
 
 struct cart *cartNew(char *userId, char *sessionId,
                      char **exclude, struct hash *oldVars)
 /* Load up cart from user & session id's.  Exclude is a null-terminated list of
  * strings to not include */
 {
 genericCgiSetup();
 
 struct cart *cart;
-struct sqlConnection *conn = cartDefaultConnector();
 char *ex;
 boolean userIdFound = FALSE, sessionIdFound = FALSE;
 
 AllocVar(cart);
 cart->hash = newHash(12);
 cart->exclude = newHash(7);
 cart->userId = userId;
 cart->sessionId = sessionId;
 
 boolean fromCli = cgiWasSpoofed(); // QA runs our CGIs from the command line and we debug from there
 
 boolean isValidHguid(char *cookieUserId); // external import from botDelay.c
 userIdFound = isValidHguid(userId);
 
 forceUserIdOrCaptcha(userId, userIdFound, fromCli);
 
 // Load userDb and sessionDb info *after* forceUserIdOrCaptcha.  loadDb will create a new record
 // if it doesn't find a matching one, and we don't need bot traffic filling our tables with junk
 
 // we rely on the cookie being validated later, so if user requested to reset the cookie settings
 // load the settings after the captcha has been checked
+struct sqlConnection *conn = cartDefaultConnector();
 if ( cgiOptionalString("ignoreCookie") != NULL )
     cart->userInfo = loadDb(conn, userDbTable(), NULL, &userIdFound);
 else
     cart->userInfo = loadDb(conn, userDbTable(), userId, &userIdFound);
 
 cart->sessionInfo = loadDb(conn, sessionDbTable(), sessionId, &sessionIdFound);
 
 if (sessionIdFound)
     cartParseOverHash(cart, cart->sessionInfo->contents);
 else if (userIdFound)
     cartParseOverHash(cart, cart->userInfo->contents);
 else
     {
     char *defaultCartContents = getDefaultCart(conn);
     cartParseOverHash(cart, defaultCartContents);