Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2e2c464

Browse files
committed
2 parents4c57b00 +1deed76 commit2e2c464

File tree

11 files changed

+205
-120
lines changed

11 files changed

+205
-120
lines changed

‎contrib/mmts/Makefile‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
MODULE_big = multimaster
2-
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 ddd.o bkb.o
2+
OBJS = multimaster.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 ddd.o bkb.o
3+
4+
overrideCPPFLAGS += -I../raftable
5+
6+
EXTRA_INSTALL = contrib/raftable contrib/mmts
37

48
EXTENSION = multimaster
59
DATA = multimaster--1.0.sql

‎contrib/mmts/multimaster.c‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757

5858
#include"multimaster.h"
5959
#include"ddd.h"
60+
#include"raftable_wrapper.h"
6061
#include"raftable.h"
6162

6263
typedefstruct {
@@ -2368,3 +2369,31 @@ MtmDetectGlobalDeadLock(PGPROC* proc)
23682369
}
23692370
returnhasDeadlock;
23702371
}
2372+
2373+
void*RaftableGet(charconst*key,int*size,RaftableTimestamp*ts,boolnowait)
2374+
{
2375+
size_ts;
2376+
char*value;
2377+
2378+
if (!MtmUseRaftable)returnNULL;
2379+
2380+
Assert(ts==NULL);/* not implemented */
2381+
value=raftable_get(key,&s);
2382+
*size=s;
2383+
returnvalue;
2384+
}
2385+
2386+
voidRaftableSet(charconst*key,voidconst*value,intsize,boolnowait)
2387+
{
2388+
if (!MtmUseRaftable)return;
2389+
2390+
raftable_set(key,value,size,nowait ?0 :-1);
2391+
}
2392+
2393+
boolRaftableCAS(charconst*key,charconst*value,boolnowait)
2394+
{
2395+
if (!MtmUseRaftable)return false;
2396+
2397+
Assert(false);/* not implemented */
2398+
return false;
2399+
}

‎contrib/mmts/raftable.h‎renamed to ‎contrib/mmts/raftable_wrapper.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef__RAFTABLE_H__
2-
#define__RAFTABLE_H__
1+
#ifndef__RAFTABLE_WRAPPER_H__
2+
#define__RAFTABLE_WRAPPER_H__
33

44
typedefstructRaftableTimestamp {
55
time_ttime;/* local time at master */

‎contrib/mmts/t/001_basic_recovery.pl‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ sub PostgresNode::inet_connstr {
3636
max_wal_senders = 10
3737
max_replication_slots = 10
3838
wal_level = logical
39-
shared_preload_libraries = 'multimaster'
39+
shared_preload_libraries = 'raftable,multimaster'
4040
multimaster.workers=4
4141
multimaster.queue_size=10485760 # 10mb
4242
);

‎contrib/raftable/README‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,24 @@ The backend can also issue commands to itself through C API.
4040

4141
C API:
4242
/* Gets value by key. Returns the value or NULL if not found. */
43-
char *raftable_get(char *key);
43+
char *raftable_get(constchar *key, size_t *vallen);
4444

4545
/*
46-
* Adds/updates value by key. Returns when the value gets replicated on
47-
* current machine. Storing NULL will delete the item from the table.
46+
* Adds/updates value by key. Returns when the value gets replicated.
47+
* Storing NULL will delete the item from the table. Gives up after
48+
* 'timeout_ms' milliseconds.
4849
*/
49-
void raftable_set(char *key, char *value);
50+
void raftable_set(constchar *key,constchar *value, size_t len, int timeout_ms);
5051

5152
/*
5253
* Iterates over all items in the table, calling func(key, value, arg)
5354
* for each of them.
5455
*/
55-
void raftable_every(void (*func)(char *, char *, void *), void *arg);
56+
void raftable_every(void (*func)(constchar *,constchar *, size_t, void *), void *arg);
5657

5758
SQL API:
5859
-- set
59-
raftable(key varchar(64), value text,tries int);
60+
raftable(key varchar(64), value text,timeout_ms int);
6061

6162
-- get
6263
raftable(key varchar(64)) returns text;

‎contrib/raftable/raftable--1.0.sql‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ AS 'MODULE_PATHNAME','raftable_sql_get'
88
LANGUAGE C;
99

1010
-- set
11-
CREATEFUNCTIONraftable(keyvarchar(64), valuetext,triesint)
11+
CREATEFUNCTIONraftable(keyvarchar(64), valuetext,timeout_msint)
1212
RETURNS void
1313
AS'MODULE_PATHNAME','raftable_sql_set'
1414
LANGUAGE C;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp