MaterializeInc / materialize

The Cloud Operational Data Store: use SQL to transform, deliver, and act on fast-changing data.
https://materialize.com
Other
5.72k stars 466 forks source link

create table from source: source limits are not applied #29556

Open nrainer-materialize opened 6 days ago

nrainer-materialize commented 6 days ago

What version of Materialize are you using?

e8e67370fc

What is the issue?

Given

$ postgres-execute connection=mz_system
ALTER SYSTEM SET max_sources = 2
ALTER SYSTEM SET max_tables = 2

> CREATE SOURCE mz_source FROM POSTGRES CONNECTION pg (PUBLICATION 'mz_source');
> CREATE SOURCE mz_source2 FROM POSTGRES CONNECTION pg (PUBLICATION 'mz_source');

the statement

> CREATE SOURCE mz_source3 FROM POSTGRES CONNECTION pg (PUBLICATION 'mz_source');

should fail with "creating source would violate max_sources limit (desired: 3, limit: 2, current: 0)" but does not.

rjobanp commented 5 days ago

@nrainer-materialize I don't know that this is an issue, or at least it's working as desired based on the current implementation:

The limit on sources actually appears to be a limit on the number of 'persist-shards' in-use by a source: https://github.com/MaterializeInc/materialize/blob/598b74acaaa574b7dd63c576a3fc5f35ae0c8c92/src/adapter/src/coord/ddl.rs#L1562-L1577

The limitation uses this method to determine how many 'persist shards' are actually needed by a given source: https://github.com/MaterializeInc/materialize/blob/598b74acaaa574b7dd63c576a3fc5f35ae0c8c92/src/catalog/src/memory/objects.rs#L793-L832

Given that the CREATE SOURCE mz_source FROM POSTGRES CONNECTION pg (PUBLICATION 'mz_source'); statement does not create any subsources, there are no data shards being created for the statement, such that it doesn't affect the overall limit.

If we want to make this limit sources based on the number of source-statements, then we would have to change this logic, but since I did not implement or design the original behavior I am not sure that is something we want. @morsapaes do you have an opinion on this?