CryoSparc 5.0.6 start fails after OS Reboot

The server has both cryosparc 5.0.6 and 4.7.1 installed. After directly executing reboot on the OS, 4.7.1 starts normally, but 5.0.6 reports the following error upon startup.
And downgrading from 5.0.6 to 4.7.1 fixed it.
Please help to see how to fix it, much appreciated!

Starting CryoSPARC master services...
CryoSPARC is not already running.
Configuring database... OK
database: started
Checking database... OK
cache: started
    ✓ cache connection succeeded
╭─────────────────────────────────────────────────── Traceback (most recent call last) ────────────────────────────────────────────────────╮
│ /work/home/wanglf/cryosparc/cryosparc_master/cli/cryosparcm.py:200 in start                                                              │
│                                                                                                                                          │
│    197 │                                                                                                                                 │
│    198 │   if startup:                                                                                                                   │
│    199 │   │   # Pre-api setup                                                                                                           │
│ ❱  200 │   │   instance.startup()                                                                                                        │
│    201 │                                                                                                                                 │
│    202 │   # start api                                                                                                                   │
│    203 │   start_service(Service.api)                                                                                                    │
│                                                                                                                                          │
│ ╭───────────────────────────────────────────────────── locals ─────────────────────────────────────────────────────╮                     │
│ │              app = True                                                                                          │                     │
│ │             core = <core.core.Core object at 0x7fdea33eab10>                                                     │                     │
│ │          db_path = PosixPath('/localdata/cryosparc_db/wanglf/database')                                          │                     │
│ │         instance = <module 'core.instance' from '/work/home/wanglf/cryosparc/cryosparc_master/core/instance.py'> │                     │
│ │ legacy_nostartup = False                                                                                         │                     │
│ │  legacy_nowebapp = False                                                                                         │                     │
│ │          service = None                                                                                          │                     │
│ │          startup = True                                                                                          │                     │
│ │          systemd = False                                                                                         │                     │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯                     │
│                                                                                                                                          │
│ /work/home/wanglf/cryosparc/cryosparc_master/core/instance.py:173 in startup                                                             │
│                                                                                                                                          │
│   170 │   config.write_legacy_job_types_available()                                                                                      │
│   171 │                                                                                                                                  │
│   172 │   logger.info("Now performing migrations")                                                                                       │
│ ❱ 173 │   migrations.migrate()                                                                                                           │
│   174 │   logger.info("Migrations complete")                                                                                             │
│   175 │                                                                                                                                  │
│   176 │   job_registers.save_job_registers()                                                                                             │
│                                                                                                                                          │
│ ╭────────────────────────────────────────── locals ──────────────────────────────────────────╮                                           │
│ │ instance_information_dict = {                                                              │                                           │
│ │                             │   'platform_node': 'login01',                                │                                           │
│ │                             │   'platform_release': '4.18.0-348.el8.0.2.x86_64',           │                                           │
│ │                             │   'platform_version': '#1 SMP Sun Nov 14 00:51:12 UTC 2021', │                                           │
│ │                             │   'platform_architecture': 'x86_64',                         │                                           │
│ │                             │   'cpu_model': 'Intel(R) Xeon(R) Gold 5218 CPU @ 2.30GHz',   │                                           │
│ │                             │   'physical_cores': 32,                                      │                                           │
│ │                             │   'max_cpu_freq': 3900.0,                                    │                                           │
│ │                             │   'total_memory': '251.29GB',                                │                                           │
│ │                             │   'available_memory': '175.58GB',                            │                                           │
│ │                             │   'used_memory': '74.16GB',                                  │                                           │
│ │                             │   ... +8                                                     │                                           │
│ │                             }                                                              │                                           │
│ ╰────────────────────────────────────────────────────────────────────────────────────────────╯                                           │
│                                                                                                                                          │
│ /work/home/wanglf/cryosparc/cryosparc_master/core/migrations.py:40 in migrate                                                            │
│                                                                                                                                          │
│    37 def migrate():                                                                                                                     │
│    38 │   logger.info("Running migrations")                                                                                              │
│    39 │   disable_long_running_task_flags()                                                                                              │
│ ❱  40 │   counters.sync_uid_counters()                                                                                                   │
│    41 │   migrate_configs()                                                                                                              │
│    42 │   migrate_tag_counts()                                                                                                           │
│    43 │   migrate_users()                                                                                                                │
│                                                                                                                                          │
│ /work/home/wanglf/cryosparc/cryosparc_master/core/counters.py:178 in sync_uid_counters                                                   │
│                                                                                                                                          │
│   175 │   logger.debug(f"Synced project uid counter to {highest_project_uid_num}")                                                       │
│   176 │   project_projections = Project.find_with_projection({}, {"uid": 1})                                                             │
│   177 │   for project_projection in project_projections:                                                                                 │
│ ❱ 178 │   │   sync_project_counters(project_projection["uid"])                                                                           │
│   179 │   logger.info("Finished syncing uid counters")                                                                                   │
│   180                                                                                                                                    │
│                                                                                                                                          │
│ ╭──────────────────────────────────────── locals ────────────────────────────────────────╮                                               │
│ │ highest_project_uid_num = 26                                                           │                                               │
│ │     highest_tag_uid_num = 1                                                            │                                               │
│ │      project_projection = {'_id': ObjectId('69d0885e38c509b4fcccd14c'), 'uid': 'P24'}  │                                               │
│ │     project_projections = <pymongo.synchronous.cursor.Cursor object at 0x7fde941871a0> │                                               │
│ ╰────────────────────────────────────────────────────────────────────────────────────────╯                                               │
│                                                                                                                                          │
│ /work/home/wanglf/cryosparc/cryosparc_master/core/counters.py:164 in sync_project_counters                                               │
│                                                                                                                                          │
│   161 │   session_projections = Session.find_with_projection({"project_uid": project_uid}, {"s                                           │
│   162 │   for session_projection in session_projections:                                                                                 │
│   163 │   │   session_uid = session_projection["session_uid"]                                                                            │
│ ❱ 164 │   │   highest_exposure_group_id = sync_exposure_group_id_counter(project_uid, session_                                           │
│   165 │   │   logger.debug(f"Synced exp_group_id counter for {project_uid}-{session_uid} to {h                                           │
│   166 │   │   highest_exposure_id = sync_exposure_uid_counter(project_uid, session_uid)                                                  │
│   167 │   │   logger.debug(f"Synced exposure id counter for {project_uid}-{session_uid} to {hi                                           │
│                                                                                                                                          │
│ ╭──────────────────────────────────────────── locals ────────────────────────────────────────────╮                                       │
│ │ highest_exposure_group_id = 1                                                                  │                                       │
│ │       highest_exposure_id = 1003                                                               │                                       │
│ │       highest_job_uid_num = 216                                                                │                                       │
│ │   highest_session_uid_num = 3                                                                  │                                       │
│ │ highest_workspace_uid_num = 3                                                                  │                                       │
│ │               project_uid = 'P24'                                                              │                                       │
│ │        session_projection = {'_id': ObjectId('6a492103c7951eba25f7c3fa'), 'session_uid': 'S2'} │                                       │
│ │       session_projections = <pymongo.synchronous.cursor.Cursor object at 0x7fde94185790>       │                                       │
│ │               session_uid = 'S2'                                                               │                                       │
│ ╰────────────────────────────────────────────────────────────────────────────────────────────────╯                                       │
│                                                                                                                                          │
│ /work/home/wanglf/cryosparc/cryosparc_master/core/counters.py:120 in sync_exposure_group_id_counter                                      │
│                                                                                                                                          │
│   117 │   │   {"project_uid": project_uid, "session_uid": session_uid}, {"exposure_groups": 1}                                           │
│   118 │   )                                                                                                                              │
│   119 │   highest_exposure_group_number = (                                                                                              │
│ ❱ 120 │   │   max(group.get("exp_group_id", 0) for group in session.get("exposure_groups", [])                                           │
│   121 │   │   if session is not None                                                                                                     │
│   122 │   │   else 0                                                                                                                     │
│   123 │   )                                                                                                                              │
│                                                                                                                                          │
│ ╭────────────────────────────────────── locals ──────────────────────────────────────╮                                                   │
│ │ project_uid = 'P24'                                                                │                                                   │
│ │     session = {'_id': ObjectId('6a492103c7951eba25f7c3fa'), 'exposure_groups': []} │                                                   │
│ │ session_uid = 'S2'                                                                 │                                                   │
│ ╰────────────────────────────────────────────────────────────────────────────────────╯                                                   │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
ValueError: max() iterable argument is empty