Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix typo in comments #7639

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .devcontainer/.psqlrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
\pset border 2
\setenv PAGER 'pspg --no-mouse -bX --no-commandbar --no-topbar'
\set HISTSIZE 100000
\set PROMPT1 '\n%[%033[1m%]%M %n@%/:%>-%p%R%[%033[0m%]%# '
\set PROMPT1 '\n%[%033[1m%]%M %n@%/:%> (PID: %p)%R%[%033[0m%]%# '
\set PROMPT2 ' '
8 changes: 4 additions & 4 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ USER citus

# build postgres versions separately for effective parrallelism and caching of already built versions when changing only certain versions
FROM base AS pg14
RUN MAKEFLAGS="-j $(nproc)" pgenv build 14.11
RUN MAKEFLAGS="-j $(nproc)" pgenv build 14.12
RUN rm .pgenv/src/*.tar*
RUN make -C .pgenv/src/postgresql-*/ clean
RUN make -C .pgenv/src/postgresql-*/src/include install
Expand All @@ -80,7 +80,7 @@ RUN cp -r .pgenv/src .pgenv/pgsql-* .pgenv/config .pgenv-staging/
RUN rm .pgenv-staging/config/default.conf

FROM base AS pg15
RUN MAKEFLAGS="-j $(nproc)" pgenv build 15.6
RUN MAKEFLAGS="-j $(nproc)" pgenv build 15.7
RUN rm .pgenv/src/*.tar*
RUN make -C .pgenv/src/postgresql-*/ clean
RUN make -C .pgenv/src/postgresql-*/src/include install
Expand All @@ -92,7 +92,7 @@ RUN cp -r .pgenv/src .pgenv/pgsql-* .pgenv/config .pgenv-staging/
RUN rm .pgenv-staging/config/default.conf

FROM base AS pg16
RUN MAKEFLAGS="-j $(nproc)" pgenv build 16.2
RUN MAKEFLAGS="-j $(nproc)" pgenv build 16.3
RUN rm .pgenv/src/*.tar*
RUN make -C .pgenv/src/postgresql-*/ clean
RUN make -C .pgenv/src/postgresql-*/src/include install
Expand Down Expand Up @@ -211,7 +211,7 @@ COPY --chown=citus:citus .psqlrc .
RUN sudo chown --from=root:root citus:citus -R ~

# sets default pg version
RUN pgenv switch 16.2
RUN pgenv switch 16.3

# make connecting to the coordinator easy
ENV PGPORT=9700
3 changes: 2 additions & 1 deletion .devcontainer/src/test/regress/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ verify_ssl = true

[packages]
mitmproxy = {editable = true, ref = "main", git = "https://github.com/citusdata/mitmproxy.git"}
construct = "==2.9.45"
construct = "*"
docopt = "==0.6.2"
cryptography = ">=41.0.4"
pytest = "*"
Expand All @@ -16,6 +16,7 @@ pytest-timeout = "*"
pytest-xdist = "*"
pytest-repeat = "*"
pyyaml = "*"
werkzeug = "==2.3.7"

[dev-packages]
black = "*"
Expand Down
424 changes: 218 additions & 206 deletions .devcontainer/src/test/regress/Pipfile.lock

Large diffs are not rendered by default.

25 changes: 13 additions & 12 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,19 @@ jobs:
runs-on: ubuntu-latest
name: Initialize parameters
outputs:
build_image_name: "citus/extbuilder"
test_image_name: "citus/exttester"
citusupgrade_image_name: "citus/citusupgradetester"
fail_test_image_name: "citus/failtester"
pgupgrade_image_name: "citus/pgupgradetester"
style_checker_image_name: "citus/stylechecker"
build_image_name: "ghcr.io/citusdata/extbuilder"
test_image_name: "ghcr.io/citusdata/exttester"
citusupgrade_image_name: "ghcr.io/citusdata/citusupgradetester"
fail_test_image_name: "ghcr.io/citusdata/failtester"
pgupgrade_image_name: "ghcr.io/citusdata/pgupgradetester"
style_checker_image_name: "ghcr.io/citusdata/stylechecker"
style_checker_tools_version: "0.8.18"
image_suffix: "-v390dab3"
pg14_version: '{ "major": "14", "full": "14.11" }'
pg15_version: '{ "major": "15", "full": "15.6" }'
pg16_version: '{ "major": "16", "full": "16.2" }'
upgrade_pg_versions: "14.11-15.6-16.2"
sql_snapshot_pg_version: "16.3"
image_suffix: "-v13fd57c"
pg14_version: '{ "major": "14", "full": "14.12" }'
pg15_version: '{ "major": "15", "full": "15.7" }'
pg16_version: '{ "major": "16", "full": "16.3" }'
upgrade_pg_versions: "14.12-15.7-16.3"
steps:
# Since GHA jobs needs at least one step we use a noop step here.
- name: Set up parameters
Expand All @@ -44,7 +45,7 @@ jobs:
needs: params
runs-on: ubuntu-20.04
container:
image: ${{ needs.params.outputs.build_image_name }}:latest
image: ${{ needs.params.outputs.build_image_name }}:${{ needs.params.outputs.sql_snapshot_pg_version }}${{ needs.params.outputs.image_suffix }}
options: --user root
steps:
- uses: actions/[email protected]
Expand Down
16 changes: 2 additions & 14 deletions .github/workflows/packaging-test-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
pg_versions: ${{ steps.get-postgres-versions.outputs.pg_versions }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Get Postgres Versions
Expand Down Expand Up @@ -51,26 +51,14 @@ jobs:
- almalinux-8
- almalinux-9
POSTGRES_VERSION: ${{ fromJson(needs.get_postgres_versions_from_file.outputs.pg_versions) }}
# Postgres removed support for CentOS 7 in PG 16. Below block is needed to
# keep the build for CentOS 7 working for PG 14 and PG 15.
# Once dependent systems drop support for Centos 7, we can remove this block.
include:
- packaging_docker_image: centos-7
POSTGRES_VERSION: 14
- packaging_docker_image: centos-7
POSTGRES_VERSION: 15
- packaging_docker_image: oraclelinux-7
POSTGRES_VERSION: 14
- packaging_docker_image: oraclelinux-7
POSTGRES_VERSION: 15

container:
image: citus/packaging:${{ matrix.packaging_docker_image }}-pg${{ matrix.POSTGRES_VERSION }}
options: --user root

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set Postgres and python parameters for rpm based distros
run: |
Expand Down
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
### citus v12.1.6 (Nov 14, 2024) ###

* Propagates `SECURITY LABEL .. ON ROLE` statements (#7304)

* Fixes crash caused by running queries with window partition (#7718)

### citus v12.1.5 (July 17, 2024) ###

* Adds support for MERGE commands with single shard distributed target tables
(#7643)

* Fixes an error with MERGE commands when insert value does not have source
distribution column (#7627)

### citus v12.1.4 (May 28, 2024) ###

* Adds null check for node in HasRangeTableRef (#7604)

### citus v12.1.3 (April 18, 2024) ###

* Allows overwriting host name for all inter-node connections by
Expand Down
22 changes: 22 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,28 @@ To get citus installed from source we run `make install -s` in the first termina

With the Citus cluster running you can connect to the coordinator in the first terminal via `psql -p9700`. Because the coordinator is the most common entrypoint the `PGPORT` environment is set accordingly, so a simple `psql` will connect directly to the coordinator.

### Debugging in the VS code

1. Start Debugging: Press F5 in VS Code to start debugging. When prompted, you'll need to attach the debugger to the appropriate PostgreSQL process.

2. Identify the Process: If you're running a psql command, take note of the PID that appears in your psql prompt. For example:
```
[local] citus@citus:9700 (PID: 5436)=#
```
This PID (5436 in this case) indicates the process that you should attach the debugger to.
If you are uncertain about which process to attach, you can list all running PostgreSQL processes using the following command:
```
ps aux | grep postgres
```

Look for the process associated with the PID you noted. For example:
```
citus 5436 0.0 0.0 0 0 ? S 14:00 0:00 postgres: citus citus
```
4. Attach the Debugger: Once you've identified the correct PID, select that process when prompted in VS Code to attach the debugger. You should now be able to debug the PostgreSQL session tied to the psql command.

5. Set Breakpoints and Debug: With the debugger attached, you can set breakpoints within the code. This allows you to step through the code execution, inspect variables, and fully debug the PostgreSQL instance running in your container.

### Getting and building

[PostgreSQL documentation](https://www.postgresql.org/support/versioning/) has a
Expand Down
1 change: 1 addition & 0 deletions citus-tools
Submodule citus-tools added at 3376bd
2 changes: 2 additions & 0 deletions src/backend/columnar/columnar_tableam.c
Original file line number Diff line number Diff line change
Expand Up @@ -3021,6 +3021,8 @@ AvailableExtensionVersionColumnar(void)

ereport(ERROR, (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("citus extension is not found")));

return NULL; /* keep compiler happy */
}


Expand Down
2 changes: 1 addition & 1 deletion src/backend/distributed/commands/multi_copy.c
Original file line number Diff line number Diff line change
Expand Up @@ -2568,7 +2568,7 @@ ShardIdForTuple(CitusCopyDestReceiver *copyDest, Datum *columnValues, bool *colu
* Find the shard interval and id for the partition column value for
* non-reference tables.
*
* For reference table, this function blindly returns the tables single
* For reference table, and single shard distributed table this function blindly returns the tables single
* shard.
*/
ShardInterval *shardInterval = FindShardInterval(partitionColumnValue, cacheEntry);
Expand Down
76 changes: 75 additions & 1 deletion src/backend/distributed/connection/connection_management.c
Original file line number Diff line number Diff line change
Expand Up @@ -773,9 +773,31 @@ ShutdownConnection(MultiConnection *connection)
if (PQstatus(connection->pgConn) == CONNECTION_OK &&
PQtransactionStatus(connection->pgConn) == PQTRANS_ACTIVE)
{
SendCancelationRequest(connection);
RemoteTransaction* transaction = &connection->remoteTransaction;
if (Enable2PCQuickResponse &&
(transaction->transactionState == REMOTE_TRANS_2PC_ABORTING ||
transaction->transactionState == REMOTE_TRANS_2PC_COMMITTING))
{
#if IN_MY_DEBUGGING_PHASE
if (LogRemoteCommands)
{
elog(NOTICE, "Not send cancel request for 2PC aborting or committing");
}
#endif
}
else
{
SendCancelationRequest(connection);
}
}
CitusPQFinish(connection);
#if IN_MY_DEBUGGING_PHASE
if (LogRemoteCommands)
{
elog(NOTICE, "connection shutdown connectionId=%ld hostname=%s port=%d",
connection->connectionId, connection->hostname, connection->port);
}
#endif
}


Expand Down Expand Up @@ -1573,6 +1595,26 @@ RemoteTransactionIdle(MultiConnection *connection)
return true;
}

#if 0
/*
* TODO: if we want to avoid shutting down the connection when aborting or committing 2PC
* distributed transactions, we need do the following:
* 1. in background worker, we need consume results of this connection
* 2. in assignning task, we should not use the this connection until the transaction is idle
*/
if (Enable2PCQuickResponse &&
(connection->remoteTransaction.transactionState == REMOTE_TRANS_2PC_COMMITTING ||
connection->remoteTransaction.transactionState == REMOTE_TRANS_2PC_ABORTING))
{
/*
* As RemoteTransactionIdle() is called from ShouldShutdownConnection() only, when
* we are aborting or committing a 2PC distributed transaction, we keep the transaction
* state by returning true to avoid shutting down the connection.
*/
return true;
}
#endif

return PQtransactionStatus(connection->pgConn) == PQTRANS_IDLE;
}

Expand Down Expand Up @@ -1684,3 +1726,35 @@ CitusModifyWaitEvent(WaitEventSet *set, int pos, uint32 events, Latch *latch)

return success;
}

/* compile with CFLAGS="-g -O0" */
void
PrintConnectionHash(void)
{
HASH_SEQ_STATUS status;
ConnectionHashEntry *entry;

elog(NOTICE, "Connection Hash:");
hash_seq_init(&status, ConnectionHash);
while ((entry = (ConnectionHashEntry *) hash_seq_search(&status)) != NULL)
{
dlist_iter iter;
elog(NOTICE, "key(Hostname=%s Port=%d User=%s Database=%s Replication=%s):",
entry->key.hostname,
entry->key.port,
entry->key.user,
entry->key.database,
entry->key.replicationConnParam ? "true" : "false");
dlist_foreach(iter, entry->connections)
{
MultiConnection *connection = dlist_container(MultiConnection, connectionNode, iter.cur);
elog(NOTICE, "value(Connection=%lu connectionState=%d xactStatus=%d pqstatus=%d busy=%s Claimed=%s)",
connection->connectionId,
connection->connectionState,
PQtransactionStatus(connection->pgConn),
PQstatus(connection->pgConn),
PQisBusy(connection->pgConn) ? "true" : "false",
connection->claimedExclusively ? "true" : "false");
}
}
}
37 changes: 24 additions & 13 deletions src/backend/distributed/connection/remote_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ int RemoteCopyFlushThreshold = 8 * 1024 * 1024;
/* GUC, determining whether statements sent to remote nodes are logged */
bool LogRemoteCommands = false;
char *GrepRemoteCommands = "";
bool Enable2PCQuickResponse = false;


static bool ClearResultsInternal(MultiConnection *connection, bool raiseErrors,
Expand Down Expand Up @@ -986,20 +987,30 @@ WaitForAllConnections(List *connectionList, bool raiseInterrupts)
}
else if (sendStatus == 0)
{
/* done writing, only wait for read events */
bool success =
CitusModifyWaitEvent(waitEventSet, event->pos,
WL_SOCKET_READABLE, NULL);
if (!success)
if (Enable2PCQuickResponse &&
(connection->remoteTransaction.transactionState == REMOTE_TRANS_2PC_COMMITTING ||
connection->remoteTransaction.transactionState == REMOTE_TRANS_2PC_ABORTING))
{
ereport(ERROR, (errcode(ERRCODE_CONNECTION_FAILURE),
errmsg("connection establishment for "
"node %s:%d failed",
connection->hostname,
connection->port),
errhint("Check both the local and remote "
"server logs for the connection "
"establishment errors.")));
/* we dont wait for 2pc committing response */
connectionIsReady = true;
}
else
{
/* done writing, only wait for read events */
bool success =
CitusModifyWaitEvent(waitEventSet, event->pos,
WL_SOCKET_READABLE, NULL);
if (!success)
{
ereport(ERROR, (errcode(ERRCODE_CONNECTION_FAILURE),
errmsg("connection establishment for "
"node %s:%d failed",
connection->hostname,
connection->port),
errhint("Check both the local and remote "
"server logs for the connection "
"establishment errors.")));
}
}
}
}
Expand Down
Loading