microsoft / pg_paxos Goto Github PK
View Code? Open in Web Editor NEWBasic implementation of Paxos and Paxos-based table replication for a cluster of PostgreSQL nodes
License: PostgreSQL License
Basic implementation of Paxos and Paxos-based table replication for a cluster of PostgreSQL nodes
License: PostgreSQL License
CREATE TABLE jobs(job_id SERIAL PRIMARY KEY, key_to_be_incremented INTEGER NOT NULL, being_worked_on_by TEXT, completed BOOLEAN DEFAULT FALSE , created_at TIMESTAMP, updated_at TIMESTAMP);
CREATE VIEW queued_jobs AS SELECT job_id, created_at, updated_at FROM jobs WHERE being_worked_on_by IS NULL AND completed IS NOT TRUE;
srangarajan=# select * from queued_jobs;
ERROR: relation "(null)" is not managed by pg_paxos
E-mail from Sri with steps to reproduce.
On 5 Mar 2016 4:22 pm, "Srivaths" [email protected] wrote:
Got a new problem here:
$ psql
psql (9.4.4)
Type "help" for help.
srangarajan=# select * from barr;
id | x | y
----+---+---
1 | 1 | 2
(1 row)
srangarajan=# insert into barr(x,y) values (1,2) returning x;
--
(1 row)
INSERT 0 1
srangarajan=# \d barr
Table "public.barr"
Column | Type | Modifiers
--------+---------+---------------------------------------------------
id | integer | not null default nextval('barr_id_seq'::regclass)
x | integer |
y | integer |
srangarajan=# insert into bar(x,y) values (1,2) returning x;
--
(1 row)
INSERT 0 1
srangarajan=# \d bar
Table "public.bar"
Column | Type | Modifiers
--------+---------+-----------
x | integer |
y | integer |
Basically pg_paxos seems to be eating up the returning value. It doesn't seem to matter if the value being returned was from an auto-incremented field or a normal field, and it also doesn't seem to matter if the table itself had an auto-incrementing column on it or not.
What I was trying to do is this:
ERROR: duplicate key value violates unique constraint "replicated_tables_pkey"
How to go about replicating a table after all nodes have joined?
By the way, I didn't find the tear-down/drop counterpart of paxos_create_group()
. Is that a TODO?
Fedora 29 gcc 8.3.1
[root@node177 pg_paxos]# make
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -O2 -fPIC -std=c99 -Wall -Wextra -Werror -Wno-unused-parameter -Iinclude -I/usr/local/pgsql/include -I. -I./ -I/usr/local/pgsql/include/server -I/usr/local/pgsql/include/internal -D_GNU_SOURCE -I/usr/include/libxml2 -c -o src/pg_paxos.o src/pg_paxos.c -MMD -MP -MF .deps/pg_paxos.Po
src/pg_paxos.c: In function ‘_PG_init’:
src/pg_paxos.c:138:22: error: assignment to ‘ProcessUtility_hook_type’ {aka ‘void (*)(struct PlannedStmt *, const char *, enum , struct ParamListInfoData *, struct QueryEnvironment *, struct _DestReceiver *, char )’} from incompatible pointer type ‘void ()(Node *, const char *, ProcessUtilityContext, struct ParamListInfoData *, DestReceiver *, char )’ {aka ‘void ()(struct Node *, const char *, enum , struct ParamListInfoData *, struct _DestReceiver *, char *)’} [-Werror=incompatible-pointer-types]
ProcessUtility_hook = PgPaxosProcessUtility;
^
In file included from /usr/local/pgsql/include/server/nodes/pg_list.h:40,
from /usr/local/pgsql/include/server/access/tupdesc.h:19,
from /usr/local/pgsql/include/server/funcapi.h:21,
from src/pg_paxos.c:17:
src/pg_paxos.c: In function ‘PgPaxosPlanner’:
/usr/local/pgsql/include/server/nodes/nodes.h:628:27: error: implicit declaration of function ‘typeof’; did you mean ‘pg_typeof’? [-Werror=implicit-function-declaration]
#define copyObject(obj) ((typeof(obj)) copyObjectImpl(obj))
^~~~~~
src/pg_paxos.c:206:23: note: in expansion of macro ‘copyObject’
Query *paxosQuery = copyObject(query);
^~~~~~~~~~
/usr/local/pgsql/include/server/nodes/nodes.h:628:40: error: expected ‘)’ before ‘copyObjectImpl’
#define copyObject(obj) ((typeof(obj)) copyObjectImpl(obj))
~ ^~~~~~~~~~~~~~
src/pg_paxos.c:206:23: note: in expansion of macro ‘copyObject’
Query *paxosQuery = copyObject(query);
^~~~~~~~~~
/usr/local/pgsql/include/server/nodes/nodes.h:628:25: error: initialization of ‘Query *’ {aka ‘struct Query *’} from ‘int’ makes pointer from integer without a cast [-Werror=int-conversion]
#define copyObject(obj) ((typeof(obj)) copyObjectImpl(obj))
^
src/pg_paxos.c:206:23: note: in expansion of macro ‘copyObject’
Query *paxosQuery = copyObject(query);
^~~~~~~~~~
src/pg_paxos.c: In function ‘PgPaxosExecutorStart’:
src/pg_paxos.c:554:3: error: implicit declaration of function ‘PreventTransactionChain’; did you mean ‘PreventInTransactionBlock’? [-Werror=implicit-function-declaration]
PreventTransactionChain(isTopLevel, "paxos commands");
^~~~~~~~~~~~~~~~~~~~~~~
PreventInTransactionBlock
src/pg_paxos.c:573:42: error: passing argument 1 of ‘pg_analyze_and_rewrite’ from incompatible pointer type [-Werror=incompatible-pointer-types]
queryTreeList = pg_analyze_and_rewrite(parseTreeNode, paxosQueryString, NULL, 0);
^~~~~~~~~~~~~
In file included from /usr/local/pgsql/include/server/tcop/utility.h:17,
from src/pg_paxos.c:48:
/usr/local/pgsql/include/server/tcop/tcopprot.h:51:14: note: expected ‘RawStmt *’ {aka ‘struct RawStmt *’} but argument is of type ‘Node *’ {aka ‘struct Node *’}
extern List *pg_analyze_and_rewrite(RawStmt *parsetree,
^~~~~~~~~~~~~~~~~~~~~~
src/pg_paxos.c:573:19: error: too few arguments to function ‘pg_analyze_and_rewrite’
queryTreeList = pg_analyze_and_rewrite(parseTreeNode, paxosQueryString, NULL, 0);
^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/local/pgsql/include/server/tcop/utility.h:17,
from src/pg_paxos.c:48:
/usr/local/pgsql/include/server/tcop/tcopprot.h:51:14: note: declared here
extern List *pg_analyze_and_rewrite(RawStmt *parsetree,
^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/local/pgsql/include/server/nodes/pg_list.h:40,
from /usr/local/pgsql/include/server/access/tupdesc.h:19,
from /usr/local/pgsql/include/server/funcapi.h:21,
from src/pg_paxos.c:17:
src/pg_paxos.c: In function ‘PgPaxosProcessUtility’:
/usr/local/pgsql/include/server/nodes/nodes.h:628:40: error: expected ‘)’ before ‘copyObjectImpl’
#define copyObject(obj) ((typeof(obj)) copyObjectImpl(obj))
~ ^~~~~~~~~~~~~~
src/pg_paxos.c:826:21: note: in expansion of macro ‘copyObject’
Node *rawQuery = copyObject(copyStatement->query);
^~~~~~~~~~
/usr/local/pgsql/include/server/nodes/nodes.h:628:25: error: initialization of ‘Node *’ {aka ‘struct Node *’} from ‘int’ makes pointer from integer without a cast [-Werror=int-conversion]
#define copyObject(obj) ((typeof(obj)) copyObjectImpl(obj))
^
src/pg_paxos.c:826:21: note: in expansion of macro ‘copyObject’
Node *rawQuery = copyObject(copyStatement->query);
^~~~~~~~~~
src/pg_paxos.c:841:46: error: passing argument 1 of ‘pg_analyze_and_rewrite’ from incompatible pointer type [-Werror=incompatible-pointer-types]
List *queryList = pg_analyze_and_rewrite(rawQuery, queryString,
^~~~~~~~
In file included from /usr/local/pgsql/include/server/tcop/utility.h:17,
from src/pg_paxos.c:48:
/usr/local/pgsql/include/server/tcop/tcopprot.h:51:14: note: expected ‘RawStmt *’ {aka ‘struct RawStmt *’} but argument is of type ‘Node *’ {aka ‘struct Node *’}
extern List *pg_analyze_and_rewrite(RawStmt *parsetree,
^~~~~~~~~~~~~~~~~~~~~~
src/pg_paxos.c:841:23: error: too few arguments to function ‘pg_analyze_and_rewrite’
List *queryList = pg_analyze_and_rewrite(rawQuery, queryString,
^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/local/pgsql/include/server/tcop/utility.h:17,
from src/pg_paxos.c:48:
/usr/local/pgsql/include/server/tcop/tcopprot.h:51:14: note: declared here
extern List *pg_analyze_and_rewrite(RawStmt *parsetree,
^~~~~~~~~~~~~~~~~~~~~~
src/pg_paxos.c:864:30: error: passing argument 1 of ‘PreviousProcessUtilityHook’ from incompatible pointer type [-Werror=incompatible-pointer-types]
PreviousProcessUtilityHook(parsetree, queryString, context,
^~~~~~~~~
src/pg_paxos.c:864:30: note: expected ‘PlannedStmt *’ {aka ‘struct PlannedStmt *’} but argument is of type ‘Node *’ {aka ‘struct Node *’}
src/pg_paxos.c:865:20: error: passing argument 5 of ‘PreviousProcessUtilityHook’ from incompatible pointer type [-Werror=incompatible-pointer-types]
params, dest, completionTag);
^~~~
src/pg_paxos.c:865:20: note: expected ‘QueryEnvironment *’ {aka ‘struct QueryEnvironment *’} but argument is of type ‘DestReceiver *’ {aka ‘struct _DestReceiver *’}
src/pg_paxos.c:865:26: error: passing argument 6 of ‘PreviousProcessUtilityHook’ from incompatible pointer type [-Werror=incompatible-pointer-types]
params, dest, completionTag);
^~~~~~~~~~~~~
src/pg_paxos.c:865:26: note: expected ‘DestReceiver *’ {aka ‘struct _DestReceiver *’} but argument is of type ‘char *’
src/pg_paxos.c:864:3: error: too few arguments to function ‘PreviousProcessUtilityHook’
PreviousProcessUtilityHook(parsetree, queryString, context,
^~~~~~~~~~~~~~~~~~~~~~~~~~
src/pg_paxos.c:869:27: error: passing argument 1 of ‘standard_ProcessUtility’ from incompatible pointer type [-Werror=incompatible-pointer-types]
standard_ProcessUtility(parsetree, queryString, context,
^~~~~~~~~
In file included from src/pg_paxos.c:48:
/usr/local/pgsql/include/server/tcop/utility.h:40:50: note: expected ‘PlannedStmt *’ {aka ‘struct PlannedStmt *’} but argument is of type ‘Node *’ {aka ‘struct Node *’}
extern void standard_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
~~~~~~~~~~~~~^~~~~
src/pg_paxos.c:870:17: error: passing argument 5 of ‘standard_ProcessUtility’ from incompatible pointer type [-Werror=incompatible-pointer-types]
params, dest, completionTag);
^~~~
In file included from src/pg_paxos.c:48:
/usr/local/pgsql/include/server/tcop/utility.h:42:25: note: expected ‘QueryEnvironment *’ {aka ‘struct QueryEnvironment *’} but argument is of type ‘DestReceiver *’ {aka ‘struct _DestReceiver *’}
QueryEnvironment *queryEnv,
~~~~~~~~~~~~~~~~~~^~~~~~~~
src/pg_paxos.c:870:23: error: passing argument 6 of ‘standard_ProcessUtility’ from incompatible pointer type [-Werror=incompatible-pointer-types]
params, dest, completionTag);
^~~~~~~~~~~~~
In file included from src/pg_paxos.c:48:
/usr/local/pgsql/include/server/tcop/utility.h:43:21: note: expected ‘DestReceiver *’ {aka ‘struct _DestReceiver *’} but argument is of type ‘char *’
DestReceiver *dest, char *completionTag);
~~~~~~~~~~~~~~^~~~
src/pg_paxos.c:869:3: error: too few arguments to function ‘standard_ProcessUtility’
standard_ProcessUtility(parsetree, queryString, context,
^~~~~~~~~~~~~~~~~~~~~~~
In file included from src/pg_paxos.c:48:
/usr/local/pgsql/include/server/tcop/utility.h:40:13: note: declared here
extern void standard_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
^~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make: *** [/usr/local/pgsql/lib/pgxs/src/makefiles/../../src/Makefile.global:899: src/pg_paxos.o] Error 1
I tried installing the pg_paxos extension from the latest code on top of postgres 9.6 on ubuntu 16.04. My make and make install of pg_paxos happen without problems. However, when I try to create the pg_paxos extension using the psql command "CREATE EXTENSION ps_paxos", I keep getting an error -- ERROR: could not access file "$libdir/pg_paxos": No such file or directory. Am I missing some steps (I am new to PG) or does the README not mention some obvious steps?
Hi,
I followed th README tutorial and everything works great.
but once I did the same of other databases it fails when I wanted other nodes to join th group
so I did as superadmin on all nodes user once everything was installed on the main node
psql -d myDB
SELECT paxos_join_group('mokka', 'host=10.0.0.1', 'host=10.0.0.49');
but
ERROR: connection "paxos_join_group" not available
CONTEXT: SQL statement "SELECT dblink_disconnect('paxos_join_group')"
PL/pgSQL function paxos_join_group(text,text,text) line 92 at PERFORM
thanks for your advice
As you can see, simple table with an insert function. Only applies the function to the node I called the function from. Also, it doesn't matter if the other node has the function or not. I understand this might be because of no support for distributed transactions and that functions are inherently transactional but there is no warning or error message for the same.
periodically see this error:
consumer_node_1.rb:19:in `exec': ERROR: column "proposal_num" does not exist (PG::UndefinedColumn)
LINE 1: SELECT greatest(max(proposal_num), current_proposal_num) + 1
^
QUERY: SELECT greatest(max(proposal_num), current_proposal_num) + 1
FROM accept_responses
CONTEXT: PL/pgSQL function paxos(text,text,bigint,text) line 177 at SQL statement
SQL statement "SELECT * FROM paxos(
current_proposer_id,
current_group_id,
current_round_num,
proposed_value)"
PL/pgSQL function paxos_apply_and_append(text,text,text) line 18 at SQL statement
SQL statement "SELECT paxos_apply_and_append($1,$2,$3)"
from consumer_node_1.rb:19:in `execute_job'
from consumer_node_1.rb:52:in `<main>'
My guess is that https://github.com/citusdata/pg_paxos/blob/master/sql/pg_paxos.sql#L454 should be:
SELECT greatest(max(**min_**proposal_num), current_proposal_num) + 1
Attempted running through the setup in the README and the extension won't compile.
Is this project being maintained at all?
I'm receiving the following error trying to setup pg_paxos on postgres 9.5.5. This is on a second node I'm trying to add to the group. Looks like this was filed before (#13) but that issue was closed without comment.
postgres=# select paxos_join_group('group0', 'host=10.10.1.1', 'host=10.10.1.2');
ERROR: connection "paxos_join_group" not available
CONTEXT: SQL statement "SELECT dblink_disconnect('paxos_join_group')"
PL/pgSQL function paxos_join_group(text,text,text) line 92 at PERFORM
What is the license for this extension? I see LGPL3 in the metadata.json, is that authoritative?
with update_some_other_foo as(
insert into rep_table values(10,1) returning x
)
update rep_table
set y = 10
from update_some_other_foo
where rep_table.x = update_some_other_foo.x;
ERROR: relation "(null)" is not managed by pg_paxos
srangarajan=# insert into target_update_table select 1, 10 from generate_series(1,10);
ERROR: relation "(null)" is not managed by pg_paxos
Just ran into this:
postgres=# INSERT INTO coordinates VALUES (1, 2);
ERROR: paxos commands cannot run inside a transaction block
STATEMENT: INSERT INTO coordinates VALUES (1, 2);
ERROR: paxos commands cannot run inside a transaction block
postgres=# ROLLBACK;
TRAP: FailedAssertion("!(IsTransactionState())", File: "relcache.c", Line: 1737)
LOG: server process (PID 11317) was terminated by signal 6: Aborted
DETAIL: Failed process was running: ROLLBACK;
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
Leaves the following back-trace:
#0 0x0000003969632625 in raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1 0x0000003969633e05 in abort () at abort.c:92
#2 0x000000000092d47e in ExceptionalCondition (conditionName=0xb31d96 "!(IsTransactionState())", errorType=0xb319e0 "FailedAssertion",
fileName=0xb31944 "relcache.c", lineNumber=1737) at assert.c:54
#3 0x000000000091ae1e in RelationIdGetRelation (relationId=3079) at relcache.c:1737
#4 0x00000000004b678c in relation_open (relationId=3079, lockmode=1) at heapam.c:1063
#5 0x00000000004b6af8 in heap_open (relationId=3079, lockmode=1) at heapam.c:1238
#6 0x0000000000603c2d in get_extension_oid (extname=0x7fe999001b21 "pg_paxos", missing_ok=1 '\001') at extension.c:127
#7 0x00007fe998fec475 in IsPgPaxosActive () at src/pg_paxos.c:268
#8 0x00007fe998fed193 in PgPaxosProcessUtility (parsetree=0x23c2b80, queryString=0x23c2198 "ROLLBACK;", context=PROCESS_UTILITY_TOPLEVEL, params=0x0,
dest=0x23c2f08, completionTag=0x7fff5a34d430 "") at src/pg_paxos.c:780
#9 0x00000000007ef9a2 in ProcessUtility (parsetree=0x23c2b80, queryString=0x23c2198 "ROLLBACK;", context=PROCESS_UTILITY_TOPLEVEL, params=0x0, dest=0x23c2f08,
completionTag=0x7fff5a34d430 "") at utility.c:330
#10 0x00000000007eea8e in PortalRunUtility (portal=0x23f4998, utilityStmt=0x23c2b80, isTopLevel=1 '\001', dest=0x23c2f08, completionTag=0x7fff5a34d430 "")
at pquery.c:1183
#11 0x00000000007eec6a in PortalRunMulti (portal=0x23f4998, isTopLevel=1 '\001', dest=0x23c2f08, altdest=0x23c2f08, completionTag=0x7fff5a34d430 "")
at pquery.c:1314
#12 0x00000000007ee1da in PortalRun (portal=0x23f4998, count=9223372036854775807, isTopLevel=1 '\001', dest=0x23c2f08, altdest=0x23c2f08,
completionTag=0x7fff5a34d430 "") at pquery.c:812
#13 0x00000000007e83a4 in exec_simple_query (query_string=0x23c2198 "ROLLBACK;") at postgres.c:1104
#14 0x00000000007ec436 in PostgresMain (argc=1, argv=0x2352580, dbname=0x23523e0 "postgres", username=0x23523c0 "amit") at postgres.c:4030
#15 0x000000000076ac8c in BackendRun (port=0x2371c90) at postmaster.c:4239
#16 0x000000000076a3f7 in BackendStartup (port=0x2371c90) at postmaster.c:3913
#17 0x0000000000766ba8 in ServerLoop () at postmaster.c:1684
#18 0x000000000076626c in PostmasterMain (argc=3, argv=0x2351590) at postmaster.c:1292
#19 0x00000000006be4c6 in main (argc=3, argv=0x2351590) at main.c:228
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.