Skip to content

onRelationshipsFlushed, onEntitiesFlushed possible unnecessarily locking? #765

@zemberdotnet

Description

@zemberdotnet

await this.lockOperation(() =>
pMap(
this.localGraphObjectStore.collectRelationshipsByStep(),
async ([stepId, relationships]) => {
const indexable = relationships.filter((r) => {
const indexMetadata = this.getIndexMetadataForGraphObjectType({
stepId,
_type: r._type,
graphObjectCollectionType: 'relationships',
});
if (typeof indexMetadata === 'undefined') {
return true;
}
return indexMetadata.enabled === true;
});
if (indexable.length) {
await flushDataToDisk({
storageDirectoryPath: stepId,
collectionType: 'relationships',
data: indexable,
pretty: this.prettifyFiles,
});
}
this.localGraphObjectStore.flushRelationships(relationships);
if (onRelationshipsFlushed) {
await onRelationshipsFlushed(relationships);
}
},
),
);

Does the onRelationshipsFlushed hook also need to be locked in the code above? My impression is that after the relationships/entities have been flushed, the hook should be free to run concurrently. If separately a step is running and able to fill the buffer, it must wait until the onRelationshipsFlushed/onEntitiesFlushed hook has finished. If the hook is an upload, that may unnecessarily slow down filling up and flushing the buffer again while uploads are happening. The hook seems like it might be unnecessarily blocking.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions