Все данные в redis, запущенные с docker -составить сброшены и превращены в резервную - PullRequest
1 голос
/ 17 марта 2020

У меня есть python код, который отправляет запросы на повторный доступ. Этот код запускается с flask. И есть также Dockerfile для его запуска.

Dockerfile выглядит следующим образом


RUN mkdir /autotutor_api

WORKDIR /autotutor_api

COPY . /autotutor_api/

EXPOSE 5000

RUN pip3 install -r requirements.txt

RUN wget https://github.com/jwijffels/udpipe.models.ud.2.0/raw/master/inst/udpipe-ud-2.0-170801/russian-syntagrus-ud-2.0-170801.udpipe -O /autotutor_api/app/recommendation_logic/processing_data/russian-syntagrus-ud-2.0-170801.udpipe

RUN wget https://dl.fbaipublicfiles.com/fasttext/vectors-crawl/cc.ru.300.vec.gz -O /autotutor_api/app/recommendation_logic/processing_data/cc.ru.300.vec.gz
RUN gzip -d  /autotutor_api/app/recommendation_logic/processing_data/cc.ru.300.vec.gz

CMD flask run --host='0.0.0.0'

docker -компонентный файл выглядит следующим образом

version: '2'
services:
    at:
        build: .
        image: auto
        ports:
            - "5000:5000"
        volumes:
            - .:/code
        depends_on:
            - redis
    redis:
        image: redis
        restart: always
        expose:
            - '6379'
        ports:
            - '6379:6379'

Я запускаю это с использованием docker-compose up и все, кажется, работает нормально. Я отправляю запросы и получаю ожидаемые результаты. Но через некоторое время я оставляю работающий сервер нетронутым и выполняю noithing и экземпляр redis, запущенный с docker -компонентного запуска, показывающего такие журналы

redis_1  | 1:S 16 Mar 2020 20:39:02.031 * Before turning into a replica, using my master parameters to synthesize a cached master: I may be able to synchronize with the new master with just a partial transfer.
redis_1  | 1:S 16 Mar 2020 20:39:02.031 * REPLICAOF 82.118.17.133:8887 enabled (user request from 'id=6 addr=194.87.103.156:38962 fd=11 name= age=1 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=47 qbuf-free=32721 obl=0 oll=0 omem=0 events=r cmd=slaveof')
redis_1  | 1:S 16 Mar 2020 20:39:02.608 * Connecting to MASTER 82.118.17.133:8887
redis_1  | 1:S 16 Mar 2020 20:39:02.609 * MASTER <-> REPLICA sync started
redis_1  | 1:S 16 Mar 2020 20:39:02.626 * Non blocking connect for SYNC fired the event.
redis_1  | 1:S 16 Mar 2020 20:39:02.649 * Master replied to PING, replication can continue...
redis_1  | 1:S 16 Mar 2020 20:39:02.683 * Trying a partial resynchronization (request caf125292337f400085b0262cde341b4c83e8bd8:1).
redis_1  | 1:S 16 Mar 2020 20:39:02.705 * Full resync from master: ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ:1
redis_1  | 1:S 16 Mar 2020 20:39:02.705 * Discarding previously cached master state.
redis_1  | 1:S 16 Mar 2020 20:39:02.705 * MASTER <-> REPLICA sync: receiving 55640 bytes from master
redis_1  | 1:S 16 Mar 2020 20:39:02.740 * MASTER <-> REPLICA sync: Flushing old data
redis_1  | 1:S 16 Mar 2020 20:39:02.741 * MASTER <-> REPLICA sync: Loading DB in memory
redis_1  | 1:S 16 Mar 2020 20:39:02.741 # Wrong signature trying to load DB from file
redis_1  | 1:S 16 Mar 2020 20:39:02.741 # Failed trying to load the MASTER synchronization DB from disk
redis_1  | 1:S 16 Mar 2020 20:39:03.613 * Connecting to MASTER 82.118.17.133:8887
redis_1  | 1:S 16 Mar 2020 20:39:03.613 * MASTER <-> REPLICA sync started
redis_1  | 1:S 16 Mar 2020 20:39:03.630 * Non blocking connect for SYNC fired the event.
redis_1  | 1:S 16 Mar 2020 20:39:03.646 # Error condition on socket for SYNC: Broken pipe
redis_1  | 1:S 16 Mar 2020 20:39:04.616 * Connecting to MASTER 82.118.17.133:8887
redis_1  | 1:S 16 Mar 2020 20:39:04.617 * MASTER <-> REPLICA sync started
redis_1  | 1:S 16 Mar 2020 20:39:04.633 * Non blocking connect for SYNC fired the event.
redis_1  | 1:S 16 Mar 2020 20:39:04.650 # Error condition on socket for SYNC: Connection reset by peer
redis_1  | 1:S 16 Mar 2020 20:39:05.620 * Connecting to MASTER 82.118.17.133:8887
redis_1  | 1:S 16 Mar 2020 20:39:05.620 * MASTER <-> REPLICA sync started
redis_1  | 1:S 16 Mar 2020 20:39:05.637 * Non blocking connect for SYNC fired the event.
redis_1  | 1:S 16 Mar 2020 20:39:05.653 # Error condition on socket for SYNC: Broken pipe
redis_1  | 1:S 16 Mar 2020 20:39:06.623 * Connecting to MASTER 82.118.17.133:8887
redis_1  | 1:S 16 Mar 2020 20:39:06.623 * MASTER <-> REPLICA sync started
redis_1  | 1:S 16 Mar 2020 20:39:06.640 * Non blocking connect for SYNC fired the event.
redis_1  | 1:S 16 Mar 2020 20:39:06.656 # Error condition on socket for SYNC: Connection reset by peer
redis_1  | 1:S 16 Mar 2020 20:39:07.626 * Connecting to MASTER 82.118.17.133:8887
redis_1  | 1:S 16 Mar 2020 20:39:07.626 * MASTER <-> REPLICA sync started
redis_1  | 1:S 16 Mar 2020 20:39:07.643 * Non blocking connect for SYNC fired the event.
redis_1  | 1:S 16 Mar 2020 20:39:07.660 # Error condition on socket for SYNC: Broken pipe
redis_1  | 1:S 16 Mar 2020 20:39:08.629 * Connecting to MASTER 82.118.17.133:8887
redis_1  | 1:S 16 Mar 2020 20:39:08.629 * MASTER <-> REPLICA sync started
redis_1  | 1:S 16 Mar 2020 20:39:08.646 * Non blocking connect for SYNC fired the event.
redis_1  | 1:S 16 Mar 2020 20:39:08.662 # Error reply to PING from master: '-Reading from master: Resource temporarily unavailable'
redis_1  | 1:S 16 Mar 2020 20:39:09.183 * Module 'system' loaded from ./red2.so
redis_1  | 1:M 16 Mar 2020 20:39:09.249 # Setting secondary replication ID to caf125292337f400085b0262cde341b4c83e8bd8, valid up to offset: 1. New replication ID is e7d42791af95ebd0a867aa0f6b364d4cfadb9c37
redis_1  | 1:M 16 Mar 2020 20:39:09.249 * MASTER MODE enabled (user request from 'id=6 addr=194.87.103.156:38962 fd=11 name= age=8 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=34 qbuf-free=32734 obl=0 oll=0 omem=0 events=r cmd=slaveof')
redis_1  | 1:M 16 Mar 2020 20:39:10.203 * Module system unloaded
redis_1  | 1:S 16 Mar 2020 21:04:59.569 * Before turning into a replica, using my master parameters to synthesize a cached master: I may be able to synchronize with the new master with just a partial transfer.
redis_1  | 1:S 16 Mar 2020 21:04:59.569 * REPLICAOF 82.118.17.133:8887 enabled (user request from 'id=8 addr=194.87.103.156:50158 fd=11 name= age=0 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=47 qbuf-free=32721 obl=0 oll=0 omem=0 events=r cmd=slaveof')
redis_1  | 1:S 16 Mar 2020 21:04:59.637 * Connecting to MASTER 82.118.17.133:8887
redis_1  | 1:S 16 Mar 2020 21:04:59.637 * MASTER <-> REPLICA sync started
redis_1  | 1:S 16 Mar 2020 21:04:59.661 * Non blocking connect for SYNC fired the event.
redis_1  | 1:S 16 Mar 2020 21:04:59.684 * Master replied to PING, replication can continue...
redis_1  | 1:S 16 Mar 2020 21:04:59.733 * Trying a partial resynchronization (request e7d42791af95ebd0a867aa0f6b364d4cfadb9c37:1).
redis_1  | 1:S 16 Mar 2020 21:04:59.757 * Full resync from master: ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ:1
redis_1  | 1:S 16 Mar 2020 21:04:59.757 * Discarding previously cached master state.
redis_1  | 1:S 16 Mar 2020 21:04:59.758 * MASTER <-> REPLICA sync: receiving 55640 bytes from master
redis_1  | 1:S 16 Mar 2020 21:04:59.805 * MASTER <-> REPLICA sync: Flushing old data
redis_1  | 1:S 16 Mar 2020 21:04:59.806 * MASTER <-> REPLICA sync: Loading DB in memory
redis_1  | 1:S 16 Mar 2020 21:04:59.806 # Wrong signature trying to load DB from file
redis_1  | 1:S 16 Mar 2020 21:04:59.807 # Failed trying to load the MASTER synchronization DB from disk
redis_1  | 1:S 16 Mar 2020 21:05:00.640 * Connecting to MASTER 82.118.17.133:8887
redis_1  | 1:S 16 Mar 2020 21:05:00.640 * MASTER <-> REPLICA sync started
redis_1  | 1:S 16 Mar 2020 21:05:00.665 * Non blocking connect for SYNC fired the event.
redis_1  | 1:S 16 Mar 2020 21:05:00.688 # Error condition on socket for SYNC: Connection reset by peer
redis_1  | 1:S 16 Mar 2020 21:05:01.643 * Connecting to MASTER 82.118.17.133:8887
redis_1  | 1:S 16 Mar 2020 21:05:01.643 * MASTER <-> REPLICA sync started
redis_1  | 1:S 16 Mar 2020 21:05:01.665 * Non blocking connect for SYNC fired the event.
redis_1  | 1:S 16 Mar 2020 21:05:01.688 # Error condition on socket for SYNC: Connection reset by peer
redis_1  | 1:S 16 Mar 2020 21:05:02.646 * Connecting to MASTER 82.118.17.133:8887
redis_1  | 1:S 16 Mar 2020 21:05:02.646 * MASTER <-> REPLICA sync started
redis_1  | 1:S 16 Mar 2020 21:05:02.669 * Non blocking connect for SYNC fired the event.
redis_1  | 1:S 16 Mar 2020 21:05:02.693 # Error condition on socket for SYNC: Connection reset by peer
redis_1  | 1:S 16 Mar 2020 21:05:03.648 * Connecting to MASTER 82.118.17.133:8887
redis_1  | 1:S 16 Mar 2020 21:05:03.649 * MASTER <-> REPLICA sync started
redis_1  | 1:S 16 Mar 2020 21:05:03.673 * Non blocking connect for SYNC fired the event.
redis_1  | 1:S 16 Mar 2020 21:05:03.697 # Error condition on socket for SYNC: Connection reset by peer
redis_1  | 1:S 16 Mar 2020 21:05:04.651 * Connecting to MASTER 82.118.17.133:8887
redis_1  | 1:S 16 Mar 2020 21:05:04.652 * MASTER <-> REPLICA sync started
redis_1  | 1:S 16 Mar 2020 21:05:04.673 * Non blocking connect for SYNC fired the event.
redis_1  | 1:S 16 Mar 2020 21:05:04.697 # Error condition on socket for SYNC: Connection reset by peer
redis_1  | 1:S 16 Mar 2020 21:05:05.654 * Connecting to MASTER 82.118.17.133:8887
redis_1  | 1:S 16 Mar 2020 21:05:05.655 * MASTER <-> REPLICA sync started
redis_1  | 1:S 16 Mar 2020 21:05:05.677 * Non blocking connect for SYNC fired the event.
redis_1  | 1:S 16 Mar 2020 21:05:05.697 # Error condition on socket for SYNC: Connection reset by peer
redis_1  | 1:S 16 Mar 2020 21:05:06.657 * Connecting to MASTER 82.118.17.133:8887
redis_1  | 1:S 16 Mar 2020 21:05:06.657 * MASTER <-> REPLICA sync started
redis_1  | 1:S 16 Mar 2020 21:05:06.681 * Non blocking connect for SYNC fired the event.
redis_1  | 1:S 16 Mar 2020 21:05:06.705 # Error condition on socket for SYNC: Connection reset by peer
redis_1  | 1:S 16 Mar 2020 21:05:06.713 * Module 'system' loaded from ./red2.so
redis_1  | 1:M 16 Mar 2020 21:05:06.784 # Setting secondary replication ID to e7d42791af95ebd0a867aa0f6b364d4cfadb9c37, valid up to offset: 1. New replication ID is cd75db63b2074bbe9a1330d8d3cc136cb06bfbf1
redis_1  | 1:M 16 Mar 2020 21:05:06.785 * MASTER MODE enabled (user request from 'id=8 addr=194.87.103.156:50158 fd=11 name= age=7 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=34 qbuf-free=32734 obl=0 oll=0 omem=0 events=r cmd=slaveof')
redis_1  | 1:M 16 Mar 2020 21:05:09.849 * Module system unloaded
redis_1  | 1:M 16 Mar 2020 21:09:14.089 * 1 changes in 3600 seconds. Saving...
redis_1  | 1:M 16 Mar 2020 21:09:14.091 * Background saving started by pid 288
redis_1  | 288:C 16 Mar 2020 21:09:14.127 * DB saved on disk
redis_1  | 288:C 16 Mar 2020 21:09:14.129 * RDB: 0 MB of memory used by copy-on-write
redis_1  | 1:M 16 Mar 2020 21:09:14.191 # Warning, detected child with unmatched pid: 243
redis_1  | 1:M 16 Mar 2020 21:09:14.292 # Warning, detected child with unmatched pid: 280
redis_1  | 1:M 16 Mar 2020 21:09:14.392 * Background saving terminated with success
packet_write_wait: Connection to 84.201.188.33 port 22: Broken pipe

Извините за такой объем текста, но я не знаю, какой именно строка в журналах я должен ссылаться. Что происходит дальше, так это то, что все данные, которые раньше хранились внутри redis, превратились в резервную копию. Это означает, что когда я подключаюсь к работающему redis с помощью sudo docker-compose exec redis sh, подключаюсь к redis-cli и спрашиваю keys *, я получаю только такие ключи, как

127.0.0.1:6379> keys *
1) "backup2"
2) "backup3" 
3) "backup1" 

Но у меня было python много других ключей код должен запрашивать во время работы.

Что бы это могло быть? Как я могу предотвратить автоматическое резервное копирование Redis c?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...