object-server partital write prevention not tested

Bug #1040883 reported by Darrell Bishop
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Object Storage (swift)
Fix Released
Low
Matthew Oliver

Bug Description

The code in the object-server's ObjectController.PUT() method which prevents partial writes (the loop around os.write(fd, chunk)), is not tested by unit tests or functional tests.

Revision history for this message
Constantine Peresypkin (constantine-q) wrote :

I don't think this one could be tested, apart from trivial write() mock.
AFAIR, write() syscall can return less bytes in case of non regular file only.
It looks like defensive style programming to me.

Revision history for this message
Darrell Bishop (darrellb) wrote :

Yes, a trivial write() mock would be sufficient to get test coverage.

On Ubuntu precise, the write(2) man page lists a number of examples of how the number of bytes written may be less than the specified count:

"The number of bytes written may be less than count if, for example, there is insufficient space on the underlying physical medium, or the RLIMIT_FSIZE resource limit is encountered (see setrlimit(2)), or the call was interrupted by a signal handler after having written less than count bytes. (See also pipe(7).)"

Revision history for this message
Constantine Peresypkin (constantine-q) wrote :

Signal will invalidate the whole block device write, i.e. not relevant for regular files.
All other errors are non-transient, there is no need to retry as it will never succeed.

Chuck Thier (cthier)
Changed in swift:
importance: Undecided → Low
Chuck Thier (cthier)
Changed in swift:
status: New → Triaged
Revision history for this message
Pete Zaitcev (zaitcev) wrote :

I see that Peter's DiskWriter does the same. This surprisingly enough works with EFULL. At first try something is written and accounted. At next try, 0 is written, OS returns an error and we get an exception.

I agree that there's no real need to write it as it's done, but it does not seem to hurt anything.

Matthew Oliver (matt-0)
Changed in swift:
assignee: nobody → Matthew Oliver (matt-0)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to swift (master)

Fix proposed to branch: master
Review: https://review.openstack.org/101743

Changed in swift:
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on swift (master)

Change abandoned by John Dickinson (<email address hidden>) on branch: master
Review: https://review.openstack.org/101743
Reason: Abandoning due to lack of activity since the last negative review. You can restore the change if you want to keep working on it.

Revision history for this message
John Dickinson (notmyname) wrote :

Matt, what's going on here?

Revision history for this message
Matthew Oliver (matt-0) wrote :

Since this bug was submitted, the code has been refactored and moved. Further, the portion of the code that deals with a partial write situation is tested and dealt with in 'test/unit/obj/test_server.py:TestObjectController.test_short_body'.

As such this bug can be marked completed.

Changed in swift:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.