Skip to content

Neptune Prod Cluster Loader Exception

0

Hello, We have function called trigger_neptune_loader_job(), which has following functionalities:

  1. Connecting to Neptune and sets up S3 access.
  2. Clears existing data in the Neptune cluster.
  3. Identify the latest data partitions in S3.
  4. Load node data from the latest partition.
  5. Load edge data from the latest partition. I'm getting an issue in the second stage(clearing data from cluster using gremlin query), function looks like this:
 # Remove data from cluster using gremlin query
        try:
            gremlin_query = "g.V().drop()"
            neptune_client.execute_gremlin_query(gremlinQuery=gremlin_query)
            logger.info("Data Deletion using gremlin query was successful.")
        except neptune_client.exceptions.ClientError as e:
            logger.error(f"Error deleting data using Gremlin Query: {e}")
            return

Error Description: When this function: trigger_neptune_loader_job() ran for the first time(i.e. when the neptune cluster was empty) the gremlin query mentioned executed properly and got passed to next functionality(Identifying latest partitions in S3) and has also loaded the data appropriately to neptune cluster(Was able to capture loadId's as well). When the same function trigger_neptune_loader_job() ran for the second time there was an issue in the second functionality, instead of deleting the data it gave me this following error: Error deleting data using Gremlin Query: An error occurred (InternalFailureException) when calling the ExecuteGremlinQuery operation (reached max retries: 4): An unexpected error has occurred in Neptune. Could some please let us know what is issue all about?

Prerequisite checks from our end: We made sure the consumer role and IAM role that we are using for this loader job has all of the necessary policies attached from our application side. Can you also suggest on how to enable detailed logging for these Neptune Service? This InternalFailureException was only seen in our Prod Cluster but never in any other Dev or other clusters that we had promoted to, could you please suggest the best practices in this case(Say that our schema got changed a lot from our current schema, what should we even do to update the data in cluster(In my case I had to delete the data and load it just because of these schema changes)

asked 2 years ago430 views

3 Answers
0

It is likely that this issue is being caused by a Timeout Exception. Amazon Neptune Database has a default timeout of 2 mins per query. For a moderately large dataset, a g.V().drop() query will take substantial time to execute. At present, all mutation queries in Neptune are executed single-threadeded. So only one execution thread is able to do this work.

Another method to quickly drop an entire cluster is to use the Fast Reset API [1]. This is also exposed via the NeptuneData APIs in boto3 [2]:

response = client.execute_fast_reset(
    action='initiateDatabaseReset'|'performDatabaseReset',
    token='string'
)

This will allow you to quickly drop an entire cluster and reset it back to it's default state without needing to do this via a query.

[1] https://docs.aws.amazon.com/neptune/latest/userguide/manage-console-fast-reset.html

[2] https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/neptunedata/client/execute_fast_reset.html

AWS

answered 2 years ago

  • Thanks Taylor, for explaining it briefly, I have tried using Fast Reset API to delete and cluster, following are my observations: . Data got deleted from the cluster. . After deletion I have loaderjob functionality in the code which is throwing me this error: Could not connect to the endpoint URL(i.e connection to the Neptune endpoint is lost). Could you please let me know what might be the issue with my trigger_neptune_loader_job()

  • The Fast Reset API will reset the cluster (which will restart the instances). They should come up within a few seconds, but it may require you to poll them for availability before you start your loader job. You could potentially use the https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/neptunedata/client/get_engine_status.html API as a means to poll for when the instance is available again.

0

The issue you're experiencing with the Neptune loader job, particularly the InternalFailureException during the data deletion step, could be due to several factors:

  1. Cluster Load: The production cluster might be under heavy load, causing the operation to time out or fail. This could explain why you're seeing the issue in production but not in development environments.

  2. Data Volume: If your production cluster contains a significantly larger volume of data compared to your development clusters, the deletion operation might be more resource-intensive and prone to failure.

  3. Concurrent Operations: There might be other operations running concurrently that are interfering with the deletion process.

  4. Timeout Settings: The operation might be timing out before it can complete. You may need to adjust the timeout settings for your Neptune client.

To address these issues and improve your process:

  1. Consider using the Neptune Bulk Delete API instead of a Gremlin query for large-scale deletions. This is often more efficient for clearing entire datasets.

  2. Implement a retry mechanism with exponential backoff for the deletion operation.

  3. Schedule the loader job during off-peak hours to minimize the impact of cluster load.

  4. For schema changes, instead of deleting and reloading all data, consider using Neptune's upsert capabilities to update existing data where possible.

  5. Enable detailed logging for Neptune by modifying the DB cluster parameter group. Set the neptune_enable_audit_log parameter to 1 to enable audit logging, which can provide more insights into query execution and errors.

  6. Use the Neptune workbench to run and analyze queries, which can provide more detailed error messages and query profiles.

  7. Consider using the Neptune Data API's ExecuteGremlinProfileQuery operation to get more detailed information about query execution and potential bottlenecks.

  8. If the issue persists, you may want to contact AWS support for a more in-depth investigation of your specific cluster configuration and workload.

Remember to thoroughly test any changes in a staging environment that closely mimics your production setup before implementing them in production.
Sources
Example: Loading Data into a Neptune DB Instance - Amazon Neptune
CancelLoaderJob - Neptune Data API
ExecuteGremlinProfileQuery - Neptune Data API
GetGremlinQueryStatus - Neptune Data API

answered 2 years ago

  • Need detailed answer from Support Team

0

Hello,

I would recommend opening up a support case to investigate the InternalFailureException happening on the delete step.

AWS Support would need to review the affected cluster, be sure to include the full error message and time of issue so the team can check further.

AWS
SUPPORT ENGINEER

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.