Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MergeSchema is ignoring SchemaExceptions #3045

Closed
t92549 opened this issue Oct 18, 2023 · 2 comments · Fixed by #3049
Closed

MergeSchema is ignoring SchemaExceptions #3045

t92549 opened this issue Oct 18, 2023 · 2 comments · Fixed by #3049
Assignees
Labels
bug Confirmed or suspected bug
Milestone

Comments

@t92549
Copy link
Contributor

t92549 commented Oct 18, 2023

Describe the bug
When the MergeSchema class applies the Schema.BaseBuilder.merge function, it catches SchemaExceptions. This is because it will retry while ignoring vertex serialisers if the error is to do with vertex serialisers:

try {
mergeSchema.merge(new Schema.Builder(update).vertexSerialiser(vertexSerialiser).build());
} catch (final SchemaException e) {
if (e.getMessage().contains(Schema.UNABLE_TO_MERGE_SCHEMAS_CONFLICT_WITH_VERTEX_SERIALISER_OPTIONS_ARE)) {
LOGGER.error(String.format("Caught SchemaException, attempting to re-merge but without vertex serialisers. Error message:%s", e.getMessage()));
//Clashing Vertex Serialiser is possibly a recoverable state, continue without using Vertex Serialisers, retain this state.
context.put(WIPE_VERTEX_SERIALISERS, true);
mergeSchema.merge(new Schema.Builder(update).vertexSerialiser(null).build());
mergeSchema.vertexSerialiser(null);
}

However, if the SchemaException is unrelated to vertex serialisers, I would expect the exception to still be thrown:

if (e.getMessage().contains(Schema.UNABLE_TO_MERGE_SCHEMAS_CONFLICT_WITH_VERTEX_SERIALISER_OPTIONS_ARE)) {
    // handle the vertex serialiser issue...
} else {
    // throw other types of SchemaException
    throw e
}

This is not the case.

Additional context
If you simply add this else block in, tests will start to fail. These tests are FederatedStoreVisibilityTest (issue: #1834) and FederatedStoreSchemaOverlapTest (issue: #2767). These tests were added as part of Gaffer 2 development to codify the new FederatedStore behaviour, however, we did not realise this behaviour was happening as a result of a bug.

Suggested fix
MergeSchema should be fixed and extended to manage all types of SchemaException.
When a SchemaException happens due to conflicting visibility property names, this can probably be intentionally ignored with a warning message.
When a SchemaException happens due to conflicting types for the same property in the same group across two subgraphs, things are more complicated. Perhaps, if the type definitions are the same the error can be ignored, and if not they can be de-duplicated.
This will likely need work on Schema.BaseBuilder.validateSharedGroupsAreCompatible

@t92549 t92549 added the bug Confirmed or suspected bug label Oct 18, 2023
@t92549 t92549 added this to the v2.1.0 milestone Oct 18, 2023
@GCHQDeveloper314
Copy link
Member

GCHQDeveloper314 commented Oct 19, 2023

If the concatenate merge function is used for a schema instead, then I assume this bug will not be seen?

@t92549
Copy link
Contributor Author

t92549 commented Oct 19, 2023

@GCHQDeveloper314 Correct, but it will not merge the schemas. Pre-2.0, the schemas were merged. Forcing concatenation of the schemas is untested behaviour, it may effect how the other merge functions work when performing a GetElements for example

@GCHQDeveloper314 GCHQDeveloper314 linked a pull request Oct 23, 2023 that will close this issue
GCHQDev404 added a commit that referenced this issue Oct 27, 2023
GCHQDev404 added a commit that referenced this issue Nov 6, 2023
* tidy up and test

* TypeDefinition Exception message improvements

* Schema Exception message improvements

* MergeSchema function context improvements.

* MergeSchema error handling improvements.

* MergeSchema error handling test changes.

* checkstyle

* PR requests

* PR requests

* PR requests

* PR requests with issues (#3051)

* PR requests with issues

* PR requests

* typo

* findBugs changes.

* spotless changes.

* typo

* PR request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed or suspected bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants