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  | Hide | Hide all | Show all
From 6ac1ad23e1e0c8fcfdbb25844ace9de3ab7a993b Mon Sep 17 00:00:00 2001
From: Nick Hastings <hastings@post.kek.jp>
Date: Tue, 19 Sep 2023 08:57:11 +0900
Subject: [PATCH 1/2] Increase MAX_OPEN_RECORDS to increase the max number of
 hot_links

In 2011 the number of hotlinks for the gsc was increased from the
default 256 to 2560. See https://elog.nd280.org/elog/GSC/425. Since we
are getting more equipment, increase to 4096. General
instructions can be found on the midas wiki at.
https://daq00.triumf.ca/MidasWiki/index.php/FAQ#Increasing_Number_of_Hot-links

When increasing this number the size of two structs will also
increase. Midas checks the size of these structs are correct, so
updated the check sizes.

DATABASE_CLIENT = 64 + 8*MAX_OPEN_ERCORDS

default:        = 64 + 8*256
                = 2112  -> Confirmed in odb.cxx

updated:        = 64 + 8*4096
                = 32832

DATABASE_HEADER = 64 + 64*DATABASE_CLIENT

default:        = 64 + 64*2112
                = 135232 -> Confirmed in odb.cxx

updated:        = 64 + 64*32832
                = 2101312
---
 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 ec6b54a1..46d653f4 100644
--- a/include/midas.h
+++ b/include/midas.h
@@ -273,7 +273,7 @@ class MJsonNode; // forward declaration from mjson.h
 #define HOST_NAME_LENGTH       256           /**< length of TCP/IP names      */
 #define MAX_CLIENTS            64            /**< client processes per buf/db */
 #define MAX_EVENT_REQUESTS     10            /**< event requests per client   */
-#define MAX_OPEN_RECORDS       256           /**< number of open DB records   */
+#define MAX_OPEN_RECORDS       4096          /**< number of open DB records   */
 #define MAX_ODB_PATH           256           /**< length of path in ODB       */
 #define BANKLIST_MAX           4096          /**< max # of banks in event     */
 #define STRING_BANKLIST_MAX    BANKLIST_MAX * 4   /**< for bk_list()          */
diff --git a/src/odb.cxx b/src/odb.cxx
index e4e2bd35..bc084612 100644
--- a/src/odb.cxx
+++ b/src/odb.cxx
@@ -1477,8 +1477,8 @@ static void db_validate_sizes()
    assert(sizeof(KEY) == 68);
    assert(sizeof(KEYLIST) == 12);
    assert(sizeof(OPEN_RECORD) == 8);
-   assert(sizeof(DATABASE_CLIENT) == 2112);
-   assert(sizeof(DATABASE_HEADER) == 135232);
+   assert(sizeof(DATABASE_CLIENT) == 32832);
+   assert(sizeof(DATABASE_HEADER) == 2101312);
    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

Attachment 2: 0002-Increase-MAX_CLIENTS-from-64-to-256.patch  2 kB  Uploaded 23 Apr 2026  | Show | Hide all | Show all
ELOG V3.1.4-2e1708b5