[SERVER-30583] Only call os.fsync if -o option is not default value in collect_resource_info.py Created: 09/Aug/17  Updated: 30/Oct/23  Resolved: 28/Aug/17

Status: Closed
Project: Core Server
Component/s: Testing Infrastructure
Affects Version/s: None
Fix Version/s: 3.5.13

Type: Bug Priority: Trivial - P5
Reporter: Eddie Louie Assignee: Eddie Louie
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: TIG 2017-09-11
Participants:

 Description   

If we use the stdout as the output stream, a call to os.fsync(fp.fileno()) will fail.

buildscripts/collect_resource_info.py -i 3
{"command": "./executables/linux_amd64/main", "cpu_sys": 0.04, "cpu_user": 0.02, "io_read": 0, "io_wait": 0, "io_write": 53248, "mem_avail": 56044023808, "mem_total": 67419119616, "mem_used": 13115392, "num_cpus": 40, "num_threads": 6, "pid": 32807, "ppid": 13988, "timestamp": {"$date": 1502306090356}}
Traceback (most recent call last):
  File "buildscripts/collect_resource_info.py", line 107, in <module>
    main()
  File "buildscripts/collect_resource_info.py", line 103, in main
    os.fsync(fp.fileno())
OSError: [Errno 22] Invalid argument

Need to conditionally call os.fsync if options.output != '-' or potentially remove this call altogether since we already have line_buffered set. Will have to test.



 Comments   
Comment by Githook User [ 28/Aug/17 ]

Author:

{'username': 'elouie99', 'name': 'Eddie Louie', 'email': 'eddie.louie@mongodb.com'}

Message: SERVER-30583 Only call os.fsync if not writing to stdout in collect_resource_info.py
Branch: master
https://github.com/mongodb/mongo/commit/98ed3fbf953bff15e2cfdd997402f56add9ce022

Comment by Max Hirschhorn [ 16/Aug/17 ]

I think it's fine to keep the fsync() call so that the contents of the file even if the background thread gets killed by the Evergreen agent. I would just conditionalize the fsync() call on whether we're writing to stdout.

if fp.fileno() != sys.stdout.fileno():
    # Flush internal buffers associated with file to disk.
    os.fsync(fp.fileno())

Generated at Thu Feb 08 04:24:19 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.