citusdata / citusdata/citus

Refactor some connection API calls into flags

Open
#1,190 3 comments 1 reaction 0 assignees View on GitHub
Dominant language
C
Stars
12.8k
Forks
794
Avg merge
2d 14h
Merged PRs (30d)
31

Description

The current approach of having to explicitly call `BeginOrContinueRemoteTransaction`, `RemoteTransactionBeginIfNecessary`, and/or `MarkRemoteTransactionCritical` on connections is a little confusing and error-prone.

A more understandable approach would be to support a flag in `GetPlacementConnection` for obtaining a connection with an already-open transaction block, e.g. `GetPlacementConnection(FOR_DML | IN_TRANSACTION, nodename, nodeport)`, which automatically ensures that the connection has a transaction block open that gets committed at the end. We should also automatically call `BeginOrContinueRemoteTransaction` if the `IN_TRANSACTION` flag is set.

The flag would only be supported by `GetPlacementConnection`, not by `StartPlacementConnection`. The latter should probably error out if it is set to avoid cases in which we forget to send BEGIN. Alternatively, we could automatically send BEGIN; by prepending it to the first command that is sent over an IN_TRANSACTION connection, which would allow us to also support `StartPlacementConnection` and would save a round-trip, though this is more complex to implement.

Similarly, we could avoid the need for calling `MarkTransactionCritical` by having a flag like `GetPlacementConnection(CRITICAL | FOR_DML | IN_TRANSACTION, nodename, nodeport)`. This would also be supported by StartPlacementConnection.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.