Repository navigation
New error codes for planning, plan complexity, and storage failures - #4792
Conversation
…n, INVALID_TABLE_DEFINITION in RecordLayerSchemaTemplate.buildRecordMetadata
…lanner and LucenePlanner
|
|
||
| /** | ||
| * Error being thrown when Cascades cannot plan a query. | ||
| * Error being thrown when the planner cannot plan a query. |
There was a problem hiding this comment.
It could be objectionable that the old planner now uses an exception class from the query/plan/cascades package of the Cascades planner. I’m not familiar with our policy regarding this. Maybe we rather want to leave the old planner untouched, or give it its own UnableToPlanException.
There was a problem hiding this comment.
Though I see that RecordQueryPlanner already has several imports from query.plan.cascades today.
There was a problem hiding this comment.
If it’s shared, then arguably the class should also be moved up to query.plan, where UnsupportedQueryException already sits. But that, of course, will break external imports…
There was a problem hiding this comment.
I now think it’s probably fine as it is now, but a second opinion would be good.
There was a problem hiding this comment.
I had some concerns initially but spotted a lot of common files and decided to keep the exception common. do not see any possible issues + such approach minimises the code
|
Consider adding the |
|
|
||
| // Class 58 - System Error | ||
| UNDEFINED_FILE("58F01"), | ||
| STORAGE_ERROR("58F02"), |
There was a problem hiding this comment.
STORAGE_ERROR("58F02") is probably fine, but taking inspiration from PostgreSQL, some closely related non-P codes we could alternatively adopt are 58030 io_error (narrower) or just 58000 system_error (i.e., the generic 58 class).
There was a problem hiding this comment.
most FDB errors are not I/O errors, I would keep STORAGE_ERROR here
There was a problem hiding this comment.
Not sure how we came to that conclusion, error category 58 corresponds to errors external to the database engine AFAIK, but FDB errors are internal to FRL, should we use a different category instead?
There was a problem hiding this comment.
I considered FDB as external part for FRL. If it is wrong, moving to XX - internal errors:
STORAGE_ERROR("XXF03")
There was a problem hiding this comment.
Debatable what the “system” is. I would have said FDB is external as well, since FRL itself just opens a client connection to FDB. Also, a different category would be useful only if our FRL clients would want to programmatically react differently to those. But to them it’s all just “the system” and beyond their control.
There was a problem hiding this comment.
Also consider what we say in the comments:
* 58 | System Error (errors external to Relational)
versus
/**
* Used for the exceptions due to internal issue of Relational, which is caused by neither clients nor upstream
* system.
*/
INTERNAL_ERROR("XX000"),
So XXF03 wouldn’t be good. I’d vote to keep 58F02.
PostgreSQL, for example, uses XX codes only for assertion-failure-type errors that “cannot happen”.
There was a problem hiding this comment.
To us, yes sure, FDB is external, but FRL is not presented to the clients as something separable from FDB, especially in a future where FRL is deployed as a service.
| } | ||
| default: | ||
| throw new RecordCoreException("unknown type of lucene query component"); | ||
| throw new VerifyException("unknown type of lucene query component"); |
There was a problem hiding this comment.
That seems like an API contract change, the PR should probably be marked as breaking change, maybe @ohadzeliger could verify whether this change is ok.
There was a problem hiding this comment.
There was a problem hiding this comment.
The switch here is exhaustive for getType(), so I was of the opinion that if this happens, it’s an internal/logic error. Hence the assertion/verify error instead of an application exception.
There was a problem hiding this comment.
Although I’m not familiar how the LucenePlanner is actually used. Are these enum values coming straight from the user and untrustworthy?
There was a problem hiding this comment.
I am also not familiar with this code, the change is probably fine, that's why I would rather have @ohadzeliger or @jjezra verify it.
There was a problem hiding this comment.
can I just revert this change to make the PR less vague?
| } | ||
| default: | ||
| throw new RecordCoreException("Unsupported boolean query occur: " + booleanQuery); | ||
| throw new VerifyException("Unsupported boolean query occur: " + booleanQuery); |
There was a problem hiding this comment.
This switch is exhaustive too, just MUST versus SHOULD.
| fileDescriptorProtoSerializer.getFileBuilder().build(), dependencies.toArray(new Descriptors.FileDescriptor[0])); | ||
| } catch (Descriptors.DescriptorValidationException e) { | ||
| throw new RelationalException(ErrorCode.SERIALIZATION_FAILURE, e).toUncheckedWrappedException(); | ||
| throw new RelationalException(ErrorCode.INVALID_TABLE_DEFINITION, e).toUncheckedWrappedException(); |
There was a problem hiding this comment.
It is not clear to me why we think this error code is more "descriptive" than SERIALIZATION_FAILURE. The caught exception e corresponds to failure to serializer the file descriptor of the schema template (and its dependencies) not a logical incorrect definition of a specific table. So a serialization failure from my perspective is more accurate.
Addendum: considering that SERIALIZATION_FAILURE falls in the category of transaction rollback handling, we could (should) probably use a different error code specific to the nature of the serialization failure (serialization keyword is a little bit overloaded here).
There was a problem hiding this comment.
introduced new SCHEMA_TEMPLATE_SERIALIZATION_FAILURE("XXF02")
There was a problem hiding this comment.
The question about XX versus the earlier class-42 INVALID_TABLE_DEFINITION is whether the user can trigger this case or not? If not, then XXF02 for an internal error would be fine. But then the question is whether it’s really worth it and useful having that code, as opposed to just XX000-with-message.
| Arguments.of(wrapFdbError(FDBError.COMMIT_UNKNOWN_RESULT), ErrorCode.TRANSACTION_RESOLUTION_UNKNOWN), | ||
| Arguments.of(wrapFdbError(FDBError.CLUSTER_VERSION_CHANGED), ErrorCode.TRANSACTION_RESOLUTION_UNKNOWN), | ||
| Arguments.of(wrapFdbError(FDBError.NOT_COMMITTED), ErrorCode.SERIALIZATION_FAILURE), | ||
| Arguments.of(wrapFdbError(FDBError.TRANSACTION_TOO_OLD), ErrorCode.SERIALIZATION_FAILURE), |
There was a problem hiding this comment.
The transaction too old error could be very useful when debugging, it would be beneficial to have an error code corresponding to it under class 40, something like 40F01. Same for the other errors below. SQL standard permits defining such specific error codes, that could convoy vendor-specific semantics.
There was a problem hiding this comment.
added TRANSACTION_TOO_OLD("40F01") and TRANSIENT_TRANSACTION_FAILURE("40F02")
There was a problem hiding this comment.
Note though that clients will often want to programmatically retry in all these conditions. So now, with three codes, they need to check for three codes in their code, instead of just SERIALIZATION_FAILURE.
The best way for them is then probably to just pattern-match the SQLSTATE for 40... in their retry logic. So the extra codes are probably fine to add, it’s just that it’s less obvious for clients how to write their code.
There was a problem hiding this comment.
This is expected. Clients usually define their business logic based upon the class of the SQL error, the LSB of the SQLSTATE are usually vendor-specific and clients are not advised to dispatch on them if they want their logic to work across different vendors.
That is why we're extra careful about the error class (and implicitly so, the category), and we're free to define the subclass as we want.
|
|
||
| // Class 58 - System Error | ||
| UNDEFINED_FILE("58F01"), | ||
| STORAGE_ERROR("58F02"), |
There was a problem hiding this comment.
Not sure how we came to that conclusion, error category 58 corresponds to errors external to the database engine AFAIK, but FDB errors are internal to FRL, should we use a different category instead?
my fault, constructed wrong test for #3583. you are right, it does not fix the issue, just introduces new codes. |
This reverts commit caf350d.
Today several different failure kinds share one
ErrorCode, so clients cannot tell them apart:UNSUPPORTED_QUERYcovers both "the planner found no plan" and unsupported syntax.RecordCoreExceptionwhen it cannot plan.UNKNOWN.INTERNAL_ERROR.SERIALIZATION_FAILURE, a transaction rollback code.This PR gives each of these failures its own code.
New error codes
TRANSACTION_RESOLUTION_UNKNOWN08007FDBStoreMaybeCommittedExceptionUNABLE_TO_PLAN0AF02UnableToPlanExceptionTRANSACTION_TOO_OLD40F01FDBStoreTransactionIsTooOldExceptionTRANSIENT_TRANSACTION_FAILURE40F02RecordCoreRetriableTransactionExceptionSTATEMENT_TOO_COMPLEX54001RecordQueryPlanComplexityExceptionTRANSACTION_TOO_LARGE54F02FDBStoreTransactionSizeExceptionKEY_TOO_LARGE54F03FDBStoreKeySizeExceptionVALUE_TOO_LARGE54F04FDBStoreValueSizeExceptionLOCK_NOT_AVAILABLE55F03FDBStoreLockTakenExceptionSCHEMA_TEMPLATE_SERIALIZATION_FAILUREXXF02DescriptorValidationExceptionwhen building metadata from a schema templateSTORAGE_ERRORXXF03FDBStoreExceptionChanges
ExceptionUtilmaps the exceptions above to the new codes. Among the retriable transaction errors(
RecordCoreRetriableTransactionException), only a transaction conflict maps toSERIALIZATION_FAILURE.Errors where the transaction may have committed get their own code, because a retry is not safe for
them.
FDBStoreLockTakenExceptionmaps toLOCK_NOT_AVAILABLE, so clients can wait before they retry.FDBExceptions.wrapExceptionwraps an FDB error withisMaybeCommitted()(for examplecommit_unknown_resultorcluster_version_changed) in the newFDBStoreMaybeCommittedException.It extends
FDBStoreRetriableException, so existing retry handling does not change.RecordQueryPlannerthrowsUnableToPlanExceptionwhen it finds no plan. It throws the newUnsupportedQueryExceptionfor a query that mixes regular and synthetic record types.LucenePlannerthrowsUnsupportedQueryExceptionfor an unsupported sort field type.Both exceptions are still
RecordCoreExceptions, and the messages do not change.PlanGeneratortranslates aSemanticExceptionthroughExceptionUtil, so it gets a specificcode instead of
INTERNAL_ERROR. Its message now starts with the exception class name, as for theother Record Layer exceptions that
ExceptionUtiltranslates.RecordLayerSchemaTemplatereports a protobuf descriptor validation failure asSCHEMA_TEMPLATE_SERIALIZATION_FAILUREinstead ofSERIALIZATION_FAILURE, which is a transactionrollback code. The descriptor is generated from the schema template, so this is an internal failure.
SplitHelperthrowsFDBStoreValueSizeExceptionfor a record that is too long and cannot be split,so it maps to
VALUE_TOO_LARGE.ORDER BYandGROUP BYdocs list0AF02for a query without a suitable index.