13e46137c78bb4ba2e27e913c958715c0508fdd6 angie Tue May 21 12:39:53 2019 -0700 Fix missing hFreeConn that caused 'too many open connections' error for sessions with lots of dbTable custom tracks. refs #22440 diff --git src/hg/hgSession/sessionData.c src/hg/hgSession/sessionData.c index 6d0b764..0323e2a 100644 --- src/hg/hgSession/sessionData.c +++ src/hg/hgSession/sessionData.c @@ -229,36 +229,39 @@ } static char *saveTrashTable(char *tableName, char *sessionDataDbPrefix, char *dbSuffix) /* Move trash tableName out of customTrash to a sessionDataDbPrefix database, unless that * has been done already. If table does not exist in either customTrash or customData*, * then return NULL; otherwise return the new database.table name. */ { char *newDbTableName = sessionDataDbTableName(tableName, sessionDataDbPrefix, dbSuffix); struct sqlConnection *conn = hAllocConn(CUSTOM_TRASH); if (! sqlTableExists(conn, newDbTableName)) { if (! sqlTableExists(conn, tableName)) { // It's possible that this table was already saved and moved out of customTrash as part // of some other saved session. We don't have a way of leaving a symlink in customTrash. - return findTableInSessionDataDbs(conn, sessionDataDbPrefix, tableName); + newDbTableName = findTableInSessionDataDbs(conn, sessionDataDbPrefix, tableName); } + else + { struct dyString *dy = sqlDyStringCreate("rename table %s to %s", tableName, newDbTableName); sqlUpdate(conn, dy->string); dyStringFree(&dy); } + } else if (sqlTableExists(conn, tableName)) errAbort("saveTrashTable: both %s and %s exist", tableName, newDbTableName); hFreeConn(&conn); return newDbTableName; } static void replaceColumnValue(struct sqlConnection *conn, char *tableName, char *columnName, char *newVal) /* Replace all tableName.columnName values with newVal. */ { struct dyString *dy = sqlDyStringCreate("update %s set %s = '%s'", tableName, columnName, newVal); sqlUpdate(conn, dy->string); dyStringFree(&dy); }