ОШИБКА Memcached: Сломанный канал / Сброс соединения по пиру - PullRequest
0 голосов
/ 25 сентября 2018

Когда я устанавливаю огромные данные с помощью Java MemcachedClient (com.whalin.MemCached), получаю ошибки broken pipe & Connection reset by peer.

Вот мой файл конфигурации.[/etc/memcached.conf]

# memcached default config file
# 2003 - Jay Bonci <jaybonci@debian.org>
# 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

Даже после того, как размер был увеличен до 4096, эти ошибки продолжают появляться.

Еще одна проблема : Не удалось получитьфайл журнала, даже если он не прокомментирован

Рабочий процесс

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 : чтение 50000 записей из БД, добавление к карте и сохранение этой картыв 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)

Сброс соединения пользователем

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)

1 Ответ

0 голосов
/ 26 сентября 2018

Я думаю, что проблема может заключаться в том, что вы пытаетесь сохранить очень большие объекты в memcache

По умолчанию memcache позволяет установить максимум 1 МБ объектов.в более новых версиях memcache вы можете установить опцию -I, чтобы увеличить размер до 128 МБ.(https://linux.die.net/man/1/memcached)

Я бы не рекомендовал его. Лучше создавать меньшие объекты.

...