Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e0ce1e7

Browse files
committed
2 parents e494d0c + 5e1f612 commit e0ce1e7

File tree

5 files changed

+93
-69
lines changed

5 files changed

+93
-69
lines changed

contrib/mmts/Dockerfile

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# vim:set ft=dockerfile:
2+
FROM debian:jessie
3+
4+
# explicitly set user/group IDs
5+
RUN groupadd -r postgres --gid=999 && useradd -r -g postgres --uid=999 postgres
6+
7+
# make the "en_US.UTF-8" locale so postgres will be utf-8 enabled by default
8+
RUN apt-get update && apt-get install -y locales && rm -rf /var/lib/apt/lists/* \
9+
&& localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
10+
ENV LANG en_US.utf8
11+
12+
# postgres build deps
13+
RUN apt-get update && apt-get install -y \
14+
git \
15+
make \
16+
gcc \
17+
gdb \
18+
libreadline-dev \
19+
bison \
20+
flex \
21+
zlib1g-dev \
22+
&& rm -rf /var/lib/apt/lists/*
23+
24+
RUN mkdir /pg && chown postgres:postgres /pg
25+
USER postgres
26+
ENV CFLAGS -O0
27+
WORKDIR /pg
28+
29+
RUN cd /pg && \
30+
git clone https://github.com/postgrespro/postgres_cluster.git --depth 1 && \
31+
cd /pg/postgres_cluster && \
32+
./configure --enable-cassert --enable-debug --prefix=/pg/install && \
33+
make -j 4 install
34+
35+
RUN mkdir /pg/data
36+
ENV PATH /pg/install/bin:$PATH
37+
ENV PGDATA /pg/data
38+
39+
# Here we can insert some ENV var to invalidate subsequent layers
40+
41+
RUN cd /pg/postgres_cluster/contrib/raftable && make install
42+
43+
RUN mkdir /pg/mmts
44+
COPY ./ /pg/mmts/
45+
RUN cd /pg/mmts && USE_PGXS=1 RAFTABLE_PATH=/pg/postgres_cluster/contrib/raftable make install
46+
47+
ENTRYPOINT ["/pg/mmts/tests2/docker-entrypoint.sh"]
48+
49+
EXPOSE 5432
50+
CMD ["postgres"]
51+

contrib/mmts/Makefile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
MODULE_big = multimaster
22
OBJS = multimaster.o raftable.o arbiter.o bytebuf.o bgwpool.o pglogical_output.o pglogical_proto.o pglogical_receiver.o pglogical_apply.o pglogical_hooks.o pglogical_config.o pglogical_relid_map.o ddd.o bkb.o spill.o
33

4-
override CPPFLAGS += -I../raftable
4+
ifndef RAFTABLE_PATH
5+
RAFTABLE_PATH = ../raftable
6+
endif
7+
8+
override CPPFLAGS += -I$(RAFTABLE_PATH)
59

610
EXTRA_INSTALL = contrib/raftable contrib/mmts
711

@@ -33,3 +37,11 @@ check:
3337
env DESTDIR='$(abs_top_builddir)'/tmp_install make install
3438
$(prove_check)
3539

40+
xcheck:
41+
#pip install -r tests2/requirements.txt
42+
docker build -t pgmmts .
43+
cd tests2 && blockade up
44+
sleep 10 # wait for mmts init
45+
cd tests2 && python test_recovery.py || true
46+
cd tests2 && blockade destroy
47+

contrib/mmts/tests2/Dockerfile

Lines changed: 0 additions & 60 deletions
This file was deleted.

contrib/mmts/tests2/Vagrantfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ Vagrant.configure(2) do |config|
2727
vb.memory = 2048
2828
end
2929

30+
config.vm.synced_folder "../../..", "/postgres_sources"
31+
3032
# there are obviously vagrant versions with a
3133
# broken 'docker' provisioner that can be fixed
3234
# by invoking an 'apt-get update' *before* docker itself

contrib/raftable/raftable.c

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,6 @@ bool raftable_set(const char *key, const char *value, size_t vallen, int timeout
332332
size_t size = sizeof(RaftableUpdate);
333333
size_t keylen = 0;
334334
timeout_t timeout;
335-
timeout_start(&timeout, timeout_ms);
336335

337336
Assert(wcfg.id >= 0);
338337

@@ -352,17 +351,37 @@ bool raftable_set(const char *key, const char *value, size_t vallen, int timeout
352351
memcpy(f->data, key, keylen);
353352
memcpy(f->data + keylen, value, vallen);
354353

355-
TIMEOUT_LOOP_START(&timeout);
354+
if (timeout_ms < 0)
356355
{
357-
if (try_sending_update(ru, size, &timeout))
356+
while (true)
358357
{
359-
pfree(ru);
360-
return true;
358+
timeout_start(&timeout, 100);
359+
360+
if (try_sending_update(ru, size, &timeout))
361+
{
362+
pfree(ru);
363+
return true;
364+
}
365+
else
366+
disconnect_leader();
367+
}
368+
}
369+
else
370+
{
371+
timeout_start(&timeout, timeout_ms);
372+
373+
TIMEOUT_LOOP_START(&timeout);
374+
{
375+
if (try_sending_update(ru, size, &timeout))
376+
{
377+
pfree(ru);
378+
return true;
379+
}
380+
else
381+
disconnect_leader();
361382
}
362-
else
363-
disconnect_leader();
383+
TIMEOUT_LOOP_END(&timeout);
364384
}
365-
TIMEOUT_LOOP_END(&timeout);
366385

367386
pfree(ru);
368387
elog(WARNING, "failed to set raftable value after %d ms", timeout_elapsed_ms(&timeout));

0 commit comments

Comments
 (0)