Skip to content

Commit

Permalink
prevent >2GB blosc compressors
Browse files Browse the repository at this point in the history
  • Loading branch information
Joran Angevaare committed Mar 3, 2023
1 parent 6f972a5 commit 602b807
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
13 changes: 9 additions & 4 deletions bin/bootstrax
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ How to use
For more info, see the documentation:
https://straxen.readthedocs.io/en/latest/bootstrax.html
"""
__version__ = '2.0.0'
__version__ = '2.0.1'

import argparse
import typing
Expand Down Expand Up @@ -799,20 +799,20 @@ def infer_records_compressor(rd, datarate, n_fails):
"""
if n_fails or datarate is None:
# Cannot infer datarate or failed before, go for fast & safe
return 'lz4' if n_fails > 1 else 'blosc'
return 'lz4' if n_fails > 1 else 'zstd'

chunk_length = (rd['daq_config']['strax_chunk_overlap'] +
rd['daq_config']['strax_chunk_length'])
chunk_size_mb = datarate*chunk_length
if datarate < 65:
# Low data rate, we can do very large compression
return 'blosc'
return 'zstd'
if chunk_size_mb > 1800:
# Extremely large chunks, let's use LZ4 because we know that it
# can handle this.
return 'lz4'
# High datarate and reasonable chunk size.
return 'blosc'
return 'zstd'


##
Expand Down Expand Up @@ -1449,6 +1449,11 @@ def process_run(rd, send_heartbeats=args.production):
if not len(md['chunks']):
fail("Processing succeeded, but no chunks were written!")

if any((chunk['n'] and not chunk['filesize'])
for chunk in md['chunks']):
# E.g. you tried compressing >2 GB chunk using blosc
fail("At least one chunk failed writing!")

log.info(f"Check that run has ended")
rd = get_run(mongo_id = rd['_id'])
end_time = rd.get('end')
Expand Down
7 changes: 6 additions & 1 deletion bin/restrax
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ How to use
For more info, see the documentation:
https://straxen.readthedocs.io/en/latest/scripts.html
"""
__version__ = '0.3.0'
__version__ = '0.3.1'

import argparse
import logging
Expand Down Expand Up @@ -553,6 +553,11 @@ class ReStrax(daq_core.DataBases):
md_in = storage_backend.get_metadata(dir_in)
md_out = storage_backend.get_metadata(dir_out)

if any((chunk['n'] and not chunk['filesize'])
for chunk in md_out['chunks']):
# E.g. you tried compressing >2 GB chunk using blosc
errors.append(f'For {dir_out}, at least one doc failed to write')

if 'exception' in md_out:
errors.append('Writing error!')

Expand Down

0 comments on commit 602b807

Please sign in to comment.