Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pybind/ceph_daemon: use small chunk for recv #13804

Merged
merged 1 commit into from Mar 20, 2017

Conversation

xiaoxichen
Copy link
Contributor

@xiaoxichen xiaoxichen commented Mar 6, 2017

socket.recv(bufsize) accept signed int in python, so if
we want to load huge data (mds -> cache_dump is an instance)
from admin socket , an EOVERFLOW exception will be throw.

Walk around this by only get 4096 bytes for each call
Signed-off-by: Xiaoxi Chen xiaoxchen@ebay.com

@@ -43,9 +43,12 @@ def do_sockio(path, cmd_bytes):
l, = struct.unpack(">I", len_str)
sock_ret = b''

got = 0
got = long(0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this breaks the python3 support.

bit = sock.recv(l - got)
# recv only accept signed int, i.e max 2GB
# walk around by limit each recv to 128M
want = min(l - got, 128*1024*1024)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd suggest define a "relatively small power of 2, for example, 4096." [1], i.e.

READ_CHUNK_SIZE = 4096

and use it instead,


[1] https://docs.python.org/2/library/socket.html

@xiaoxichen xiaoxichen force-pushed the fix_adminsocket branch 2 times, most recently from a9164e3 to 367a035 Compare March 8, 2017 15:26
@xiaoxichen xiaoxichen changed the title pybind/ceph_daemon: limit each socket.recv to 128M pybind/ceph_daemon: use small chunk for recv Mar 8, 2017
@xiaoxichen
Copy link
Contributor Author

@tchaikov addressed

@@ -45,7 +46,10 @@ def do_sockio(path, cmd_bytes):

got = 0
while got < l:
bit = sock.recv(l - got)
# recv only accept signed int, i.e max 2GB
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

recv() receives ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

@@ -45,7 +46,10 @@ def do_sockio(path, cmd_bytes):

got = 0
while got < l:
bit = sock.recv(l - got)
# recv() receives signed int, i.e max 2GB
# walk around by request max READ_CHUNK_SIZE per call.
Copy link
Contributor

@tchaikov tchaikov Mar 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

workaround by capping, might want to update the commit message also.

@@ -45,7 +46,10 @@ def do_sockio(path, cmd_bytes):

got = 0
while got < l:
bit = sock.recv(l - got)
# recv() receives signed int, i.e max 2GB
# walkaround by capping READ_CHUNK_SIZE per call.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/walkaround/workaround/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, thanks for the english lesson :)

socket.recv(bufsize) accept signed int in python, so if
we want to load huge data (mds -> cache_dump is an instance)
from admin socket , an EOVERFLOW exception will be throw.

Workaround by capping READ_CHUNK_SIZE(4096) bytes each call.

Signed-off-by: Xiaoxi Chen <xiaoxchen@ebay.com>
@tchaikov tchaikov merged commit cbd3f6c into ceph:master Mar 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants