Skip to content

Support COPY command with a TransactionBoundDatabase#3826

Merged
ScottDugas merged 18 commits intoFoundationDB:mainfrom
ScottDugas:copy-with-record-store
Mar 9, 2026
Merged

Support COPY command with a TransactionBoundDatabase#3826
ScottDugas merged 18 commits intoFoundationDB:mainfrom
ScottDugas:copy-with-record-store

Conversation

@ScottDugas
Copy link
Copy Markdown
Collaborator

@ScottDugas ScottDugas commented Jan 7, 2026

Breaking Changes

Some TransactionBound classes now require that a keyspace is provided. TransactionBoundEmbeddedRelationalEngine is still backwards compatible, but some of the more internal classes require a keyspace.

Change

This supports using the COPY command with a TransactionBoundDatabase. It requires connecting a KeySpace to TransactionBoundEmbeddedRelationalEngine.

Resolves: #3918

@ScottDugas ScottDugas added enhancement New feature or request breaking change Changes that are not backwards compatible labels Jan 8, 2026
@ScottDugas ScottDugas force-pushed the copy-with-record-store branch from 9521618 to 492ced1 Compare January 14, 2026 21:45
This requires the database to provide the actual KeySpace under use
This required quite a bit more boiler plate than I would like, but
there's not quite enough tests to really warrant generating some
sort of pseudo DSL to generate metadata's more efficiently.
The constructor is unused, and anyone should really be interacting
with the engine.
@ScottDugas ScottDugas force-pushed the copy-with-record-store branch from 954fd34 to 068a82e Compare January 26, 2026 14:41
This reuses some of the helpers I already had, and adds a couple
more for better DRY, and focus of the test code.
* @throws RelationalException if this catalog does not have a {@link KeySpace} associated
*/
@Nonnull
KeySpace getKeySpace() throws RelationalException;
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The catalog felt, to me like the most appropriate place to expose this, but I don't have exhaustive knowledge of the state available during query execution, so if there is something more appropriate, let me know.

Copy link
Copy Markdown
Contributor

@hatyo hatyo Mar 3, 2026

Choose a reason for hiding this comment

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

The initial API of the catalog considers the KeySpace to be an internal details, that some catalog implementations might rely upon to organize their metadata data, i.e. the RecordLayerStoreCatalog. It feels a bit awkward to me to push the KeySpace to this level.

Could you please consider push this method down to the RecordLayerStoreCatalog level?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I can't really push it entirely down into RecordLayerStoreCatalog because the point of this change is to allow it to work with a TransactionBoundDatabase and a HollowStoreCatalog. It seems wrong to then have the COPY command be doing multiple different instanceof checks to figure out whether it can support copying.
I did change it to:

public KeySpacePath getKeySpacePath(@Nonnull final URI uri)

which you can see here: ccff9cc

But thinking about it more, I decided that it would be better to have a DataLayout interface, and an implementation based on KeySpace that COPY could use. I'm reticent to put methods on DataLayout because I don't think we have a clear consensus on how we want to handle data layout going forward, and if we diverge from KeySpace, we'll probably want have interfaces in record-layer-core to support it.

That being said, I am working under the assumption that StoreCatalog is intended to be relatively internal, and is only exposed to support TransactionBoundDatabase.

@ScottDugas ScottDugas added the DO NOT MERGE do not merge label Feb 5, 2026
@ScottDugas ScottDugas requested a review from hatyo February 5, 2026 16:36
@ScottDugas ScottDugas marked this pull request as ready for review February 10, 2026 17:18
@ScottDugas ScottDugas removed the DO NOT MERGE do not merge label Feb 10, 2026
* {@link com.apple.foundationdb.relational.recordlayer.query.CopyPlan}, and trying to access it will throw a clear
* error if it is not provided here.
*/
public InMemoryCatalog(@Nullable final KeySpace keySpace) {
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.

It feels wrong to add the keySpace here since this catalog is a mere in-memory metadata map.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I think I only added this because 1/3 of the usages had a KeySpace created immediately above it.
I changed it to just not support this, which means it doesn't support COPY, which seems fine.
Outside of testing, I'm not sure why you would use InMemoryCatalog, since the schema is not persisted, you won't be able to read persisted data if the client restarts.

.add("test_id", UUID.randomUUID());

catalog = new InMemoryCatalog();
catalog = new InMemoryCatalog(keySpace);
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.

Could we create a RecordLayerStoreCatalog with a proper key space instead?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Since InMemoryCatalog no longer takes a keySpace there are no longer changes here.

@ScottDugas ScottDugas force-pushed the copy-with-record-store branch from 64d6446 to 535aa14 Compare March 6, 2026 21:35
Copy link
Copy Markdown
Contributor

@hatyo hatyo left a comment

Choose a reason for hiding this comment

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

LGTM

@ScottDugas ScottDugas merged commit edbca9f into FoundationDB:main Mar 9, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change Changes that are not backwards compatible enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support COPY command with TransactionBoundDatabase

2 participants