p2panda / aquadoggo

Node for the p2panda network handling validation, storage, aggregation and replication
GNU Affero General Public License v3.0
70 stars 5 forks source link

`schema` tasks issued too frequently #580

Closed sandreae closed 1 year ago

sandreae commented 1 year ago

We have ended up with logic in two places accounting for the same situation: materialising documents when their dependencies arrive late/out of order. Originally we never accounted for this by default, only for schema documents, this is taken care of in the schema task itself, by handling both schema_definition_v1 and schema_field_definition_v1 operations, and in the case of the latter, doing a reverse lookup for any parents.

https://github.com/p2panda/aquadoggo/blob/a831c87844e795cbb9a8013f0f39f935460ef065/aquadoggo/src/materializer/tasks/schema.rs#L39-L43

Now though, since https://github.com/p2panda/aquadoggo/pull/434 we take care of this case for all documents, by issuing dependency tasks for any potential "inverse relations" (identified by schema) of the tasks' document view:

https://github.com/p2panda/aquadoggo/blob/a831c87844e795cbb9a8013f0f39f935460ef065/aquadoggo/src/materializer/tasks/dependency.rs#L144-L147

The solution is to remove the logic in the schema task, and only issue schema tasks for schema_definition_v1 documents. Additionally we should check in the schema task if the schema already exists before undertaking any more expensive work. These changes are the same as what was needed in blob task https://github.com/p2panda/aquadoggo/issues/574