Skip to content

Don't use 2PC if COPY operates on a single shard - #7187

Draft
Naisila Puka (naisila) wants to merge 1 commit into
mainfrom
naisila/single_shard_copy
Draft

Don't use 2PC if COPY operates on a single shard#7187
Naisila Puka (naisila) wants to merge 1 commit into
mainfrom
naisila/single_shard_copy

Conversation

@naisila

@naisila Naisila Puka (naisila) commented Sep 7, 2023

Copy link
Copy Markdown
Contributor

See discussion in:
#7160 (comment)

Fixes #7176

/* all modifications use 2PC */
Use2PCForCoordinatedTransaction();
/* all modifications use 2PC unless we only touch a single shard */
if (!IsCitusTableTypeCacheEntry(cacheEntry, SINGLE_SHARD_DISTRIBUTED) &&

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we check if shardIntervalList has more than 1 shards?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I also think that we should consider generalizing the code.

I think we should probably postpone the 2PC decision until CitusCopyDestReceiverShutdown(), there iterate over shardStateHash and make sure that only a single node is involved (CopyShardState->placementStateList->groupId).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably

I said probably because I cannot exactly remember whether we ever clear/invalidate CopyShardState before copy finishes. If so, we cannot follow this suggestion

@marcocitus Marco Slot (marcocitus) Sep 8, 2023

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we probably need similar checks as in Activate2PCIfModifyingTransactionExpandsToNewNode to handle cases where the transaction already did stuff on other nodes

(the current change seems potentially faulty)

@naisila
Naisila Puka (naisila) marked this pull request as draft September 12, 2023 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve or throw proper error for COPY FROM in Citus foreign tables

4 participants