kcsurapaneni
kcsurapaneni

Reputation: 814

Memcached ERROR : Broken pipe / Connection reset by peer

When I am setting the huge data using Java MemcachedClient(com.whalin.MemCached), getting the broken pipe & Connection reset by peer errors.

Here is my configuration file. [/etc/memcached.conf]

# memcached default config file
# 2003 - Jay Bonci <[email protected]>
# This configuration file is read by the start-memcached script provided as
# part of the Debian GNU/Linux distribution.

# Run memcached as a daemon. This command is implied, and is not needed for the
# daemon to run. See the README.Debian that comes with this package for more
# information.
-d

# Log memcached's output to /var/log/memcached
logfile /var/log/memcached.log

# Be verbose
 -v

# Be even more verbose (print client commands as well)
 -vv

# Start with a cap of 64 megs of memory. It's reasonable, and the daemon default
# Note that the daemon will grow to this size, but does not start out holding this much
# memory
-m 4096

# Default connection port is 11211
-p 11311

# Run the daemon as root. The start-memcached will default to running as root if no
# -u command is present in this config file
-u memcache

# Specify which IP address to listen on. The default is to listen on all IP addresses
# This parameter is one of the only security measures that memcached has, so make sure
# it's listening on a firewalled interface.
-l 127.0.0.1

# Limit the number of simultaneous incoming connections. The daemon default is 1024
# -c 1024

# Lock down all paged memory. Consult with the README and homepage before you do this
# -k

# Return error when memory is exhausted (rather than removing items)
# -M

# Maximize core file limit
# -r

Even after the size has been increased to 4096, still those errors are coming.

One more Issue : Not able to get the log file, even it is un-commented

Running process

memcache  9304     1  0 11:26 ?        00:00:00 /usr/bin/memcached -v -vv -m 4096 -p 11311 -u memcache -l 127.0.0.1

FYI : Reading the 50000 records from DB, adding to the map and storing that map into the Memcache.

Broken Pipe :

java.io.IOException: Broken pipe
        at sun.nio.ch.FileDispatcherImpl.write0(Native Method)
        at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47)
        at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93)
        at sun.nio.ch.IOUtil.write(IOUtil.java:51)
        at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:471)
        at com.schooner.MemCached.SockOutputStream.writeToChannel(Unknown Source)
        at com.schooner.MemCached.SockOutputStream.write(Unknown Source)
        at java.io.ObjectOutputStream$BlockDataOutputStream.drain(ObjectOutputStream.java:1877)
        at java.io.ObjectOutputStream$BlockDataOutputStream.setBlockDataMode(ObjectOutputStream.java:1786)
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1189)
        at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
        at java.util.HashMap.internalWriteEntries(HashMap.java:1790)
        at java.util.HashMap.writeObject(HashMap.java:1363)
        at sun.reflect.GeneratedMethodAccessor100.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:1128)
        at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1496)
        at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
        at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
        at com.schooner.MemCached.ObjectTransCoder.encode(Unknown Source)
        at com.schooner.MemCached.AbstractTransCoder.encode(Unknown Source)
        at com.schooner.MemCached.AscIIClient.set(Unknown Source)
        at com.schooner.MemCached.AscIIClient.set(Unknown Source)
        at com.whalin.MemCached.MemCachedClient.set(Unknown Source)

Connection reset by user

java.io.IOException: Connection reset by peer
        at sun.nio.ch.FileDispatcherImpl.write0(Native Method)
        at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47)
        at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93)
        at sun.nio.ch.IOUtil.write(IOUtil.java:51)
        at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:471)
        at com.schooner.MemCached.SockOutputStream.writeToChannel(Unknown Source)
        at com.schooner.MemCached.SockOutputStream.write(Unknown Source)
        at java.io.ObjectOutputStream$BlockDataOutputStream.drain(ObjectOutputStream.java:1877)
        at java.io.ObjectOutputStream$BlockDataOutputStream.setBlockDataMode(ObjectOutputStream.java:1786)
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1189)
        at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
        at java.util.HashMap.internalWriteEntries(HashMap.java:1790)
        at java.util.HashMap.writeObject(HashMap.java:1363)
        at sun.reflect.GeneratedMethodAccessor100.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:1128)
        at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1496)
        at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
        at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
        at com.schooner.MemCached.ObjectTransCoder.encode(Unknown Source)
        at com.schooner.MemCached.AbstractTransCoder.encode(Unknown Source)
        at com.schooner.MemCached.AscIIClient.set(Unknown Source)
        at com.schooner.MemCached.AscIIClient.set(Unknown Source)
        at com.whalin.MemCached.MemCachedClient.set(Unknown Source)

Upvotes: 1

Views: 3241

Answers (1)

pratikvasa
pratikvasa

Reputation: 2045

I think the issue might be that you are trying to store very large objects to memcache

By default memcache allows a max of 1MB objects to be set. in newer versions of memcache you can set the -I option to increase the size to a max of 128MB. (https://linux.die.net/man/1/memcached)

I would not recommend it though. Its better to create smaller objects.

Upvotes: 1

Related Questions