Merges two adjacent shards in the Readwrite state. You can specify a shard ID in the request. Then, Log Service finds the adjacent shard and combines the two shards into a single shard.

Request syntax

POST /logstores/<logstorename>/shards/<shardid>? action=merge HTTP/1.1
Authorization: <AuthorizationString>
Date: <GMT Date>
Host: <Project Endpoint>
x-log-apiversion: 0.6.0
x-log-signaturemethod: hmac-sha1

Request parameters

  • Request headers

    The MergeShards operation does not have operation-specific request headers. For information about the common request headers of Log Service API operations, see Common request headers.

  • Parameters
    Parameter Type Required Example Description
    logstoreName string Yes logstorename The name of the Logstore.
    shardid int Yes 30 The ID of the shard.

Response parameters

  • Response headers

    The MergeShards operation does not have operation-specific response headers. For information about the common response headers of Log Service API operations, see Common response headers.

  • Response elements
    An array that consists of the parameters of three shards is returned. The first shard is the merged shard. The other two shards are the original shards.
    [
        {
            'shardID': 167, 
            'status': 'readwrite', 
            'inclusiveBeginKey': 'e0000000000000000000000000000000',
            'createTime': 1453953105,
            'exclusiveEndKey': 'ffffffffffffffffffffffffffffffff'
        }, 
        {
            'shardID': 30, 
            'status': 'readonly', 
            'inclusiveBeginKey': 'e0000000000000000000000000000000', 
            'createTime': 0, 
            'exclusiveEndKey': 
            'e7000000000000000000000000000000'
        },
        {
            'shardID': 166, 
            'status': 'readonly', 
            'inclusiveBeginKey': 'e7000000000000000000000000000000', 
            'createTime': 1453953073, 
            'exclusiveEndKey': 'ffffffffffffffffffffffffffffffff'
        }
    ]

Examples

  • Sample requests
    POST /logstores/logstorename/shards/30? action=merge
    Header :
    {
        "Content-Length": 0, 
        "x-log-signaturemethod": "hmac-sha1", 
        "x-log-bodyrawsize": 0, 
        "User-Agent": "log-python-sdk-v-0.6.0", 
        "Host": "ali-test-project.cn-hangzhou.sls.aliyuncs.com", 
        "Date": "Thu, 12 Nov 2015 03:40:31 GMT", 
        "x-log-apiversion": "0.6.0", 
        "Authorization": "LOG <yourAccessKeyId>:<yourSignature>"
    }
  • Sample success responses
    Header:
    {
        "content-length": "57", 
        "server": "nginx/1.6.1", 
        "connection": "close", 
        "date": "Thu, 12 Nov 2015 03:40:31 GMT", 
        "content-type": "application/json", 
        "x-log-requestid": "56440A2F99248C050600C74C"
    }
    Body :
    [
        {
            'shardID': 167, 
            'status': 'readwrite', 
            'inclusiveBeginKey': 'e0000000000000000000000000000000',
            'createTime': 1453953105,
            'exclusiveEndKey': 'ffffffffffffffffffffffffffffffff'
        }, 
        {
            'shardID': 30, 
            'status': 'readonly', 
            'inclusiveBeginKey': 'e0000000000000000000000000000000', 
            'createTime': 0, 
            'exclusiveEndKey': 
            'e7000000000000000000000000000000'
        },
        {
            'shardID': 166, 
            'status': 'readonly', 
            'inclusiveBeginKey': 'e7000000000000000000000000000000', 
            'createTime': 1453953073, 
            'exclusiveEndKey': 'ffffffffffffffffffffffffffffffff'
        }
    ]

Error codes

HTTP status code Error code Error message Description
404 LogStoreNotExist logstore {logstoreName} does not exist. The error message returned because the specified Logstore does not exist.
400 ParameterInvalid invalid shard id. The error message returned because the specified shard ID is invalid.
400 ParameterInvalid can not merge the last shard. The error message returned because the last shard cannot be merged.
500 InternalServerError Specified Server Error Message. The error message returned because an internal server error has occurred.
400 LogStoreWithoutShard logstore has no shard. The error message returned because no shards exist in the Logstore.

For more information about the error codes, see Common error codes.