From f57524d8144f6fada94e133dbb769877a5d02593 Mon Sep 17 00:00:00 2001 From: Marko Malenic Date: Tue, 5 Mar 2024 11:20:31 +1100 Subject: [PATCH] fix(filemanager): sqlx queries --- ...4c56ffc4c72f7cbd933fe91e5f9a12f3a2d1807bd3496d7ee134.json} | 4 ++-- ...213654668cd5dc62997148a6768d5d19f5176257c1ebb5c09fc2.json} | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) rename lib/workload/stateless/filemanager/.sqlx/{query-c0649cd0af246c20b2ee60a3b27e2130db9c1526f858159de63c3af383f4a3b6.json => query-9fd0e02337484c56ffc4c72f7cbd933fe91e5f9a12f3a2d1807bd3496d7ee134.json} (59%) rename lib/workload/stateless/filemanager/.sqlx/{query-6515aa29536fb79eb777151f8650c8eec41a9bd4bcc72a06d36a5d0eed482115.json => query-df0e4c422260213654668cd5dc62997148a6768d5d19f5176257c1ebb5c09fc2.json} (56%) diff --git a/lib/workload/stateless/filemanager/.sqlx/query-c0649cd0af246c20b2ee60a3b27e2130db9c1526f858159de63c3af383f4a3b6.json b/lib/workload/stateless/filemanager/.sqlx/query-9fd0e02337484c56ffc4c72f7cbd933fe91e5f9a12f3a2d1807bd3496d7ee134.json similarity index 59% rename from lib/workload/stateless/filemanager/.sqlx/query-c0649cd0af246c20b2ee60a3b27e2130db9c1526f858159de63c3af383f4a3b6.json rename to lib/workload/stateless/filemanager/.sqlx/query-9fd0e02337484c56ffc4c72f7cbd933fe91e5f9a12f3a2d1807bd3496d7ee134.json index 34ab88e3f..a837b73cf 100644 --- a/lib/workload/stateless/filemanager/.sqlx/query-c0649cd0af246c20b2ee60a3b27e2130db9c1526f858159de63c3af383f4a3b6.json +++ b/lib/workload/stateless/filemanager/.sqlx/query-9fd0e02337484c56ffc4c72f7cbd933fe91e5f9a12f3a2d1807bd3496d7ee134.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "-- Update the matching s3_objects which should be re-ordered based on the created event. Returns the\n-- data associated with the event before the update, if an update occurred.\n\n-- First, unnest the input parameters into a query.\nwith input as (\n select\n *\n from unnest(\n $1::uuid[],\n $2::text[],\n $3::text[],\n $4::timestamptz[],\n $5::integer[],\n $6::text[],\n $7::timestamptz[],\n $8::text[],\n $9::storage_class[],\n $10::text[],\n $11::text[]\n ) as input (\n s3_object_id,\n bucket,\n key,\n created_date,\n size,\n checksum,\n last_modified_date,\n e_tag,\n storage_class,\n version_id,\n created_sequencer\n )\n),\n-- Then, select the objects that need to be updated.\ncurrent_objects as (\n select\n s3_object.*,\n input.s3_object_id as input_id,\n input.bucket as input_bucket,\n input.key as input_key,\n input.version_id as input_version_id,\n input.created_sequencer as input_created_sequencer,\n input.created_date as input_created_date,\n input.size as input_size,\n input.checksum as input_checksum,\n input.last_modified_date as input_last_modified_date,\n input.e_tag as input_e_tag,\n input.storage_class as input_storage_class\n from s3_object\n -- Grab the relevant values to update with.\n join input on\n input.bucket = s3_object.bucket and\n input.key = s3_object.key and\n input.version_id = s3_object.version_id\n -- Lock this pre-emptively for the update.\n for update\n),\n-- And filter them to the objects that need to be updated.\nobjects_to_update as (\n select\n *\n from current_objects\n where\n -- Check the sequencer condition. We only update if there is a created\n -- sequencer that is closer to the deleted sequencer.\n current_objects.deleted_sequencer > current_objects.input_created_sequencer and\n (\n -- Updating a null sequencer doesn't cause the event to be reprocessed.\n current_objects.created_sequencer is null or\n -- If a sequencer already exists this event should be reprocessed because this\n -- sequencer could belong to another object.\n current_objects.created_sequencer < current_objects.input_created_sequencer\n )\n -- And there should not be any objects with a created sequencer that is the same as the input created\n -- sequencer because this is a duplicate event that would cause a constraint error in the update.\n and current_objects.input_created_sequencer not in (\n select created_sequencer from current_objects where created_sequencer is not null\n )\n),\n-- Finally, update the required objects.\nupdate as (\n update s3_object\n set created_sequencer = objects_to_update.input_created_sequencer,\n created_date = objects_to_update.input_created_date,\n size = coalesce(objects_to_update.input_size, objects_to_update.size),\n checksum = coalesce(objects_to_update.input_checksum, objects_to_update.checksum),\n last_modified_date = coalesce(objects_to_update.input_last_modified_date, objects_to_update.last_modified_date),\n e_tag = coalesce(objects_to_update.e_tag, objects_to_update.e_tag),\n storage_class = objects_to_update.storage_class,\n number_reordered = s3_object.number_reordered +\n -- Note the asymmetry between this and the reorder for deleted query.\n case when objects_to_update.deleted_sequencer is not null or objects_to_update.created_sequencer is not null then\n 1\n else\n 0\n end\n from objects_to_update\n where s3_object.s3_object_id = objects_to_update.s3_object_id\n)\n-- Return the old values because these need to be reprocessed.\nselect\n -- Note, this is the passed through value from the input in order to identify this event later.\n input_id as \"s3_object_id!\",\n bucket,\n key,\n created_date as event_time,\n last_modified_date,\n e_tag,\n storage_class as \"storage_class?: StorageClass\",\n version_id,\n created_sequencer as sequencer,\n number_reordered,\n number_duplicate_events,\n size,\n -- This is used to simplify re-constructing the FlatS3EventMessages in the Lambda. I.e. this update detected an\n -- out of order created event, so return a created event back.\n 'Created' as \"event_type!: EventType\"\nfrom objects_to_update;\n", + "query": "-- Update the matching s3_objects which should be re-ordered based on the created event. Returns the\n-- data associated with the event before the update, if an update occurred.\n\n-- First, unnest the input parameters into a query.\nwith input as (\n select\n *\n from unnest(\n $1::uuid[],\n $2::text[],\n $3::text[],\n $4::timestamptz[],\n $5::integer[],\n $6::text[],\n $7::timestamptz[],\n $8::text[],\n $9::storage_class[],\n $10::text[],\n $11::text[]\n ) as input (\n s3_object_id,\n bucket,\n key,\n created_date,\n size,\n checksum,\n last_modified_date,\n e_tag,\n storage_class,\n version_id,\n created_sequencer\n )\n),\n-- Then, select the objects that need to be updated.\ncurrent_objects as (\n select\n s3_object.*,\n input.s3_object_id as input_id,\n input.bucket as input_bucket,\n input.key as input_key,\n input.version_id as input_version_id,\n input.created_sequencer as input_created_sequencer,\n input.created_date as input_created_date,\n input.size as input_size,\n input.checksum as input_checksum,\n input.last_modified_date as input_last_modified_date,\n input.e_tag as input_e_tag,\n input.storage_class as input_storage_class\n from s3_object\n -- Grab the relevant values to update with.\n join input on\n input.bucket = s3_object.bucket and\n input.key = s3_object.key and\n input.version_id is not distinct from s3_object.version_id\n -- Lock this pre-emptively for the update.\n for update\n),\n-- And filter them to the objects that need to be updated.\nobjects_to_update as (\n select\n *\n from current_objects\n where\n -- Check the sequencer condition. We only update if there is a created\n -- sequencer that is closer to the deleted sequencer.\n current_objects.deleted_sequencer > current_objects.input_created_sequencer and\n (\n -- Updating a null sequencer doesn't cause the event to be reprocessed.\n current_objects.created_sequencer is null or\n -- If a sequencer already exists this event should be reprocessed because this\n -- sequencer could belong to another object.\n current_objects.created_sequencer < current_objects.input_created_sequencer\n )\n -- And there should not be any objects with a created sequencer that is the same as the input created\n -- sequencer because this is a duplicate event that would cause a constraint error in the update.\n and current_objects.input_created_sequencer not in (\n select created_sequencer from current_objects where created_sequencer is not null\n )\n),\n-- Finally, update the required objects.\nupdate as (\n update s3_object\n set created_sequencer = objects_to_update.input_created_sequencer,\n created_date = objects_to_update.input_created_date,\n size = coalesce(objects_to_update.input_size, objects_to_update.size),\n checksum = coalesce(objects_to_update.input_checksum, objects_to_update.checksum),\n last_modified_date = coalesce(objects_to_update.input_last_modified_date, objects_to_update.last_modified_date),\n e_tag = coalesce(objects_to_update.e_tag, objects_to_update.e_tag),\n storage_class = objects_to_update.storage_class,\n number_reordered = s3_object.number_reordered +\n -- Note the asymmetry between this and the reorder for deleted query.\n case when objects_to_update.deleted_sequencer is not null or objects_to_update.created_sequencer is not null then\n 1\n else\n 0\n end\n from objects_to_update\n where s3_object.s3_object_id = objects_to_update.s3_object_id\n)\n-- Return the old values because these need to be reprocessed.\nselect\n -- Note, this is the passed through value from the input in order to identify this event later.\n input_id as \"s3_object_id!\",\n bucket,\n key,\n created_date as event_time,\n last_modified_date,\n e_tag,\n storage_class as \"storage_class?: StorageClass\",\n version_id,\n created_sequencer as sequencer,\n number_reordered,\n number_duplicate_events,\n size,\n -- This is used to simplify re-constructing the FlatS3EventMessages in the Lambda. I.e. this update detected an\n -- out of order created event, so return a created event back.\n 'Created' as \"event_type!: EventType\"\nfrom objects_to_update;\n", "describe": { "columns": [ { @@ -143,5 +143,5 @@ null ] }, - "hash": "c0649cd0af246c20b2ee60a3b27e2130db9c1526f858159de63c3af383f4a3b6" + "hash": "9fd0e02337484c56ffc4c72f7cbd933fe91e5f9a12f3a2d1807bd3496d7ee134" } diff --git a/lib/workload/stateless/filemanager/.sqlx/query-6515aa29536fb79eb777151f8650c8eec41a9bd4bcc72a06d36a5d0eed482115.json b/lib/workload/stateless/filemanager/.sqlx/query-df0e4c422260213654668cd5dc62997148a6768d5d19f5176257c1ebb5c09fc2.json similarity index 56% rename from lib/workload/stateless/filemanager/.sqlx/query-6515aa29536fb79eb777151f8650c8eec41a9bd4bcc72a06d36a5d0eed482115.json rename to lib/workload/stateless/filemanager/.sqlx/query-df0e4c422260213654668cd5dc62997148a6768d5d19f5176257c1ebb5c09fc2.json index ba27d4bf6..d9b45ac03 100644 --- a/lib/workload/stateless/filemanager/.sqlx/query-6515aa29536fb79eb777151f8650c8eec41a9bd4bcc72a06d36a5d0eed482115.json +++ b/lib/workload/stateless/filemanager/.sqlx/query-df0e4c422260213654668cd5dc62997148a6768d5d19f5176257c1ebb5c09fc2.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "-- Update the matching s3_objects which should be re-ordered based on the deleted event. Returns the\n-- data associated with the event before the update, if an update occurred.\n\n-- First, unnest the input parameters into a query.\nwith input as (\n select\n *\n from unnest(\n $1::uuid[],\n $2::text[],\n $3::text[],\n $4::timestamptz[],\n $5::text[],\n $6::text[]\n ) as input (\n s3_object_id,\n bucket,\n key,\n deleted_date,\n version_id,\n deleted_sequencer\n )\n),\n-- Then, select the objects that match the bucket, key and version_id\ncurrent_objects as (\n select\n s3_object.*,\n input.s3_object_id as input_id,\n input.bucket as input_bucket,\n input.key as input_key,\n input.version_id as input_version_id,\n input.deleted_sequencer as input_deleted_sequencer,\n input.deleted_date as input_deleted_date\n from s3_object\n -- Grab the relevant values to update with.\n join input on\n input.bucket = s3_object.bucket and\n input.key = s3_object.key and\n input.version_id = s3_object.version_id\n -- Lock this pre-emptively for the update.\n for update\n),\n-- And filter them to the objects that need to be updated.\nobjects_to_update as (\n select\n *\n from current_objects\n where\n -- Check the sequencer condition. We only update if there is a deleted\n -- sequencer that is closer to the created sequencer.\n current_objects.created_sequencer < current_objects.input_deleted_sequencer and\n (\n -- Updating a null sequencer doesn't cause the event to be reprocessed.\n current_objects.deleted_sequencer is null or\n -- If a sequencer already exists this event should be reprocessed because this\n -- sequencer would belong to another object.\n current_objects.deleted_sequencer > current_objects.input_deleted_sequencer\n )\n -- And there should not be any objects with a deleted sequencer that is the same as the input deleted\n -- sequencer because this is a duplicate event that would cause a constraint error in the update.\n and current_objects.input_deleted_sequencer not in (\n select deleted_sequencer from current_objects where deleted_sequencer is not null\n )\n),\n-- Finally, update the required objects.\nupdate as (\n update s3_object\n set deleted_sequencer = objects_to_update.input_deleted_sequencer,\n deleted_date = objects_to_update.input_deleted_date,\n number_reordered = s3_object.number_reordered +\n case when objects_to_update.deleted_sequencer is null then 0 else 1 end\n from objects_to_update\n where s3_object.s3_object_id = objects_to_update.s3_object_id\n)\n-- Return the old values because these need to be reprocessed.\nselect\n -- Note, this is the passed through value from the input in order to identify this event later.\n input_id as \"s3_object_id!\",\n bucket,\n key,\n deleted_date as event_time,\n last_modified_date,\n e_tag,\n storage_class as \"storage_class?: StorageClass\",\n version_id,\n deleted_sequencer as sequencer,\n number_reordered,\n number_duplicate_events,\n size,\n -- This is used to simplify re-constructing the FlatS3EventMessages in the Lambda. I.e. this update detected an\n -- out of order deleted event, so return a deleted event back.\n 'Deleted' as \"event_type!: EventType\"\nfrom objects_to_update;\n", + "query": "-- Update the matching s3_objects which should be re-ordered based on the deleted event. Returns the\n-- data associated with the event before the update, if an update occurred.\n\n-- First, unnest the input parameters into a query.\nwith input as (\n select\n *\n from unnest(\n $1::uuid[],\n $2::text[],\n $3::text[],\n $4::timestamptz[],\n $5::text[],\n $6::text[]\n ) as input (\n s3_object_id,\n bucket,\n key,\n deleted_date,\n version_id,\n deleted_sequencer\n )\n),\n-- Then, select the objects that match the bucket, key and version_id\ncurrent_objects as (\n select\n s3_object.*,\n input.s3_object_id as input_id,\n input.bucket as input_bucket,\n input.key as input_key,\n input.version_id as input_version_id,\n input.deleted_sequencer as input_deleted_sequencer,\n input.deleted_date as input_deleted_date\n from s3_object\n -- Grab the relevant values to update with.\n join input on\n input.bucket = s3_object.bucket and\n input.key = s3_object.key and\n input.version_id is not distinct from s3_object.version_id\n -- Lock this pre-emptively for the update.\n for update\n),\n-- And filter them to the objects that need to be updated.\nobjects_to_update as (\n select\n *\n from current_objects\n where\n -- Check the sequencer condition. We only update if there is a deleted\n -- sequencer that is closer to the created sequencer.\n current_objects.created_sequencer < current_objects.input_deleted_sequencer and\n (\n -- Updating a null sequencer doesn't cause the event to be reprocessed.\n current_objects.deleted_sequencer is null or\n -- If a sequencer already exists this event should be reprocessed because this\n -- sequencer would belong to another object.\n current_objects.deleted_sequencer > current_objects.input_deleted_sequencer\n )\n -- And there should not be any objects with a deleted sequencer that is the same as the input deleted\n -- sequencer because this is a duplicate event that would cause a constraint error in the update.\n and current_objects.input_deleted_sequencer not in (\n select deleted_sequencer from current_objects where deleted_sequencer is not null\n )\n),\n-- Finally, update the required objects.\nupdate as (\n update s3_object\n set deleted_sequencer = objects_to_update.input_deleted_sequencer,\n deleted_date = objects_to_update.input_deleted_date,\n number_reordered = s3_object.number_reordered +\n case when objects_to_update.deleted_sequencer is null then 0 else 1 end\n from objects_to_update\n where s3_object.s3_object_id = objects_to_update.s3_object_id\n)\n-- Return the old values because these need to be reprocessed.\nselect\n -- Note, this is the passed through value from the input in order to identify this event later.\n input_id as \"s3_object_id!\",\n bucket,\n key,\n deleted_date as event_time,\n last_modified_date,\n e_tag,\n storage_class as \"storage_class?: StorageClass\",\n version_id,\n deleted_sequencer as sequencer,\n number_reordered,\n number_duplicate_events,\n size,\n -- This is used to simplify re-constructing the FlatS3EventMessages in the Lambda. I.e. this update detected an\n -- out of order deleted event, so return a deleted event back.\n 'Deleted' as \"event_type!: EventType\"\nfrom objects_to_update;\n", "describe": { "columns": [ { @@ -113,5 +113,5 @@ null ] }, - "hash": "6515aa29536fb79eb777151f8650c8eec41a9bd4bcc72a06d36a5d0eed482115" + "hash": "df0e4c422260213654668cd5dc62997148a6768d5d19f5176257c1ebb5c09fc2" }