Bug #32033 Request for build option for setting SO_SNDBUF+SO_RCVBUF at IPPROTO_TCP level.
Submitted: 1 Nov 2007 15:22 Modified: 4 Mar 2013 11:12
Reporter: Peter Edwards Email Updates:
Status: Closed Impact on me:
Category:MySQL Server: Compiling Severity:S4 (Feature request)
Version:all OS:Any
Assigned to: CPU Architecture:Any
Tags: build, Contribution, setsockopt, SO_RCVBUF, SO_SNDBUF, socket

[1 Nov 2007 15:22] Peter Edwards
Sorry if this is not the correct place to ask about a feature request.

I support MySQL on a system (VMS) that has a very small default TCP send and receive buffer size, unfortuently I have not been able to get this system setting changed, connections are made over links with some latency and the throughput is limited.

Being able to specify the SO_SNDBUF and SO_RCVBUF sizes as a compile time option would allow the MySQL client/server libraries to make more efficient use of TCPIP in an environment where the defaults are inappropriately small and there is some latency, and result sets exceed the buffer sizes.

I may well be the only person in this situation, and I anticipate this request is likely to fall on stoney ground, however, I thought no harm in asking.

How to repeat:
On a system with small default TCP send and receive buffer sizes, such as 6144 bytes, profile a connection from a client to a host (the host can be on regular Linux box) where the network has some latency (anything over 10ms should be enough), ensure the dataset returned is greater than the buffer size, so a quick query that returns 1MB of data would suffice.

On Linux the middle value of:


can be used to change the intial buffer sizes, (depending on your kernel and if it has autotuning /proc/sys/net/ipv4/tcp_moderate_rcvbuf may need to be removed or set to 0).

On any (but especially a recent) Linux Kernel it may be difficult (if not impossible) to simulate a VMS TCPIP stack with small default send and receive buffer sizes.

Suggested fix:
Here is the start of a patch:

/* set SO_SND_BUF and SO_RCV_BUF at IPPROTO_TCP level, when possible */
int vio_snd_rcv_buf(Vio *vio, int buf_size);

    vio_snd_rcv_buf(vio,36864); /* make this a build option #ifdef */

int vio_snd_rcv_buf(Vio * vio, int buf_size)
  int r_snd=0;
  int r_rcv=0;
  int r=0;
  DBUG_PRINT("enter",("buf_size: %d",buf_size));

  if (vio->type != VIO_TYPE_NAMEDPIPE)
      if (buf_size)
          r_snd = setsockopt(vio->sd, SOL_SOCKET, SO_SNDBUF, (char*)&buf_size, sizeof(buf_size));
          r_rcv = setsockopt(vio->sd, SOL_SOCKET, SO_RCVBUF, (char*)&buf_size, sizeof(buf_size));

  if (r_snd)
      DBUG_PRINT("warning", ("Couldn't set socket option for SNDBUF"));
      r= -1;

  if (r_rcv)
      DBUG_PRINT("warning", ("Couldn't set socket option for RCVBUF"));
      r= -1;

  DBUG_PRINT("exit", ("%d", r));

Thanks for reading.

Peter (Stig) Edwards
[8 Nov 2007 0:59] Valeriy Kravchuk
Thank you for a reasonable feature request and patch ideas contributed.
[8 Jun 2009 22:32] liz drachnik
Hello Peter - 

In order for us to continue the process of reviewing your contribution to MySQL - We need you to review and sign the Sun|MySQL contributor agreement (the "SCA")

The process is explained here: 

Getting a signed/approved SCA on file will help us facilitate your contribution-- this one, and others in the future.

Thank you ! 

Liz Drachnik  - Program Manager - MySQL
[4 Mar 2013 11:12] Yngve Svendsen
Closing as rejected. Quite a long time has passed, and it is highly uncertain whether going through the legal process is worth it for an enhancement that is somewhat "exotic".