[
https://issues.apache.org/jira/browse/HDDS-10324?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17820567#comment-17820567
]
Mohammad Arafat Khan commented on HDDS-10324:
---------------------------------------------
I've tested this in my local Docker environment, and it indeed reveals a bug
that was overlooked. Here's what's happening: when we create an object with the
same key name as one already in the database, the request is forwarded to the
OM side of the code, specifically to the *{{OmKeyRequest}}* class, which
contains a method called {{{}*prepareFileInfo()*{}}}. This method persists the
data to the {*}{{openKeyTable}}{*}. Initially, it checks if a key with the same
name exists. If it does, it proceeds to update it with new {*}data size{*},
*modification* {*}time{*}, {*}updateID{*}, and {*}replicationConfig{*}.
However, it fails to update the metadata of the overridden file. Consequently,
the old metadata stored earlier is retained, which is the root cause of the
problem and requires fixing.
I have a patch ready that I am currently testing in my local environment, and I
will submit a pull request ASAP.
> Metadata are not updated when keys are overwritten
> --------------------------------------------------
>
> Key: HDDS-10324
> URL: https://issues.apache.org/jira/browse/HDDS-10324
> Project: Apache Ozone
> Issue Type: Bug
> Components: S3
> Reporter: Duong
> Assignee: Mohammad Arafat Khan
> Priority: Major
>
> When updating an existing key, the metadata are not updated.
> This can be reproduced on a docker cluster
> {code:java}
> # create bucket
> sh-4.2$ aws s3api --endpoint http://localhost:9878 create-bucket
> --bucket=bucket
> {
> "Location": "http://localhost:9878/bucket"
> }
> # reate key
> sh-4.2$ aws s3api --endpoint http://localhost:9878 put-object --bucket
> bucket --key test --metadata "X-Amz-Meta-Testmetadatakey"="test" --body
> README.md
> {
> "ETag": "\"d5568357dc4eaab62bd52312f884c9be\""
> }
> sh-4.2$ aws s3api --endpoint http://localhost:9878 head-object --bucket
> bucket --key test
>
> {
> "LastModified": "Wed, 07 Feb 2024 19:32:53 GMT",
> "ContentLength": 4068,
> "ETag": "\"d5568357dc4eaab62bd52312f884c9be\"",
> "CacheControl": "no-cache",
> "ContentType": "binary/octet-stream",
> "Expires": "Wed, 07 Feb 2024 19:50:43 GMT",
> "Metadata": {
> "X-Amz-Meta-Testmetadatakey": "test"
> }
> }
> # overriding the key with new metadata
> sh-4.2$ aws s3api --endpoint http://localhost:9878 put-object --bucket
> bucket --key test --metadata "X-Amz-Meta-Testmetadatakey"="updated" --body
> README.md
> {
> "ETag": "\"d5568357dc4eaab62bd52312f884c9be\""
> }
> # metadata is not updated
> sh-4.2$ aws s3api --endpoint http://localhost:9878 head-object --bucket
> bucket --key test
> {
> "LastModified": "Wed, 07 Feb 2024 19:51:11 GMT",
> "ContentLength": 4068,
> "ETag": "\"d5568357dc4eaab62bd52312f884c9be\"",
> "CacheControl": "no-cache",
> "ContentType": "binary/octet-stream",
> "Expires": "Wed, 07 Feb 2024 19:51:13 GMT",
> "Metadata": {
> "X-Amz-Meta-Testmetadatakey": "test"
> }
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]