Back Midas Rome Roody Rootana
  Midas DAQ System  Not logged in ELOG logo
Entry  23 Apr 2026, Pavel Murat, Bug Report, increasing the max number of hot links in ODB 
This is a draft message, edit and submit it to make it permanent  
Message ID: 3211     Entry time: 23 Apr 2026     In reply to: 3210
Author: Nick Hastings 
Topic: Bug Report 
Subject: increasing the max number of hot links in ODB 
> Dear MIDAS experts,
> 
> when I attempted to increase the max number of hotlinks in ODB , defined as 
> 
> #define MAX_OPEN_RECORDS       256           /**< number of open DB records   */
> 
> I started running into an assertion in midas/src/odb.cxx
> 
> https://bitbucket.org/tmidas/midas/src/fa5457b5274a6b42c5ed8b6dea5e3cdd43de38fe/src/odb.cxx#lines-1525 :
> 
>   assert(sizeof(DATABASE_CLIENT) == 2112);
> 
> is it possible that the size of the DATABASE_CLIENT structure should be checked against 64+sizeof(OPEN_RECORD)*MAX_OPEN_RECORDS ?
> - 64 clearly can be expressed in a better maintainable form

Yes, this assert needs to be updated if you increase MAX_OPEN_RECORDS. See 
https://daq00.triumf.ca/MidasWiki/index.php/FAQ#Increasing_Number_of_Hot-links

> UPDATE: similar consideration holds for the size of the DATABLE_HEADER structure, which is also checked against a constant
> 
> https://bitbucket.org/tmidas/midas/src/fa5457b5274a6b42c5ed8b6dea5e3cdd43de38fe/src/odb.cxx#lines-1526

Yes DATABASE_HEADER can also be updated, but the associated assert()s need to be updated too.

FYI I have done both of these things and have attached patches.

Cheers,

Nick.
Attachment 1: 0001-Increase-MAX_OPEN_RECORDS-to-increase-the-max-number.patch  2 kB  Uploaded 23 Apr 2026  | Show | Hide all | Show all
Attachment 2: 0002-Increase-MAX_CLIENTS-from-64-to-256.patch  2 kB  Uploaded 23 Apr 2026  | Hide | Hide all | Show all
From d0b0c5f316944a3133a26cc5340ec293f719b500 Mon Sep 17 00:00:00 2001
From: Nick Hastings <hastings@post.kek.jp>
Date: Tue, 19 Sep 2023 09:43:04 +0900
Subject: [PATCH 2/2] Increase MAX_CLIENTS from 64 to 256

In 2012 MAX_CLIENTS was increased from 64 to 128 for the t2kgsc. This
allowed double the number of frontends or clients. See elog entry at
https://elog.nd280.org/elog/GSC/808

For the new gsc this is further increased to 256. This necessitates
updating the size checks of the BUFFER_HEADER and DATABASE_HEADER structs.

BUFFER_HEADER = 32 + 7*4 + 256*MAX_CLIENTS

current:      = 32 + 7*4 + 256*64
              = 16444 -> Confirmed in odb.cxx

updated:      = 32 + 7*4 + 256*256
              = 65596

DATABASE_HEADER = 32 + 8*4 + 32832*MAX_CLIENTS

current:        = 32 + 8*4 + 32832*64
                = 2101312 -> Confirmed in odb.cxx

updated:        = 32 + 8*4 + 32832*256
                = 8405056

N.B. When the corresponding change was made in 2012 the value of
MAX_RPC_CONNECTION was increased from 64 to 96. No equivalent change
is made now since it was removed from midas in 2021 commit 9c93bc7f
"RPC_SERVER_ACCEPTION cleanup".
---
 include/midas.h | 2 +-
 src/odb.cxx     | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/midas.h b/include/midas.h
index 46d653f4..43ca476e 100644
--- a/include/midas.h
+++ b/include/midas.h
@@ -271,7 +271,7 @@ class MJsonNode; // forward declaration from mjson.h
 
 #define NAME_LENGTH            32            /**< length of names, mult.of 8! */
 #define HOST_NAME_LENGTH       256           /**< length of TCP/IP names      */
-#define MAX_CLIENTS            64            /**< client processes per buf/db */
+#define MAX_CLIENTS            256           /**< client processes per buf/db */
 #define MAX_EVENT_REQUESTS     10            /**< event requests per client   */
 #define MAX_OPEN_RECORDS       4096          /**< number of open DB records   */
 #define MAX_ODB_PATH           256           /**< length of path in ODB       */
diff --git a/src/odb.cxx b/src/odb.cxx
index bc084612..b94cef29 100644
--- a/src/odb.cxx
+++ b/src/odb.cxx
@@ -1469,7 +1469,7 @@ static void db_validate_sizes()
 #ifdef OS_LINUX
    assert(sizeof(EVENT_REQUEST) == 16); // ODB v3
    assert(sizeof(BUFFER_CLIENT) == 256);
-   assert(sizeof(BUFFER_HEADER) == 16444);
+   assert(sizeof(BUFFER_HEADER) == 65596);
    assert(sizeof(HIST_RECORD) == 20);
    assert(sizeof(DEF_RECORD) == 40);
    assert(sizeof(INDEX_RECORD) == 12);
@@ -1478,7 +1478,7 @@ static void db_validate_sizes()
    assert(sizeof(KEYLIST) == 12);
    assert(sizeof(OPEN_RECORD) == 8);
    assert(sizeof(DATABASE_CLIENT) == 32832);
-   assert(sizeof(DATABASE_HEADER) == 2101312);
+   assert(sizeof(DATABASE_HEADER) == 8405056);
    assert(sizeof(EVENT_HEADER) == 16);
    //assert(sizeof(EQUIPMENT_INFO) == 696); has been moved to dynamic checking inside mhttpd.c
    assert(sizeof(EQUIPMENT_STATS) == 24);
-- 
2.47.3

ELOG V3.1.4-2e1708b5