Got it

Disk Storage Space Is Not Released After Documents Are Deleted from Elasticsearch

149 0 0 0 0

Hello all, 

This case mainly talks about "Disk Storage Space Is Not Released After Documents Are Deleted from Elasticsearch"

Applicable Version

6.5.x

Context and Symptom

A document of an index is deleted on Elasticsearch. After the document is deleted, the disk space is not released but may occupy more space.

1. The myindex-002 index occupies 8.6 GB disk space before its document is deleted.

disk space

2. After half of the files are deleted, the occupied disk space increases to 10.4 GB.

occupied

3. After the segment merge is completed, the occupied disk space changes to 5.3 GB instead of the expected 4.3 GB.

segment merget

Cause Analysis

1. Each segment of Elasticsearch maintains a .del file. When the document is deleted on Elasticsearch, the document is marked as deleted in the .del file but its data is not cleared on the disk.

2. When Elasticsearch performs segment merge, segments are selected and merged to generate a new segment. In this case, the documents marked as deleted are not processed. Therefore, the disk space is released. By default, Elasticsearch selects some segments for merging. Therefore, the disk space is completely released only after all segments are processed.

3. You can set max_num_segments to 1 and perform the force merge operation to trigger Elasticsearch to process all segments of the index.

Solution

Perform the forcemerge operation and set max_num_segments to 1 to merge the indexes into one segment. In this way, the space can be completely released and the query performance can be improved.

curl -XPOST --negotiate -k -u : "https://ip:port//{index_name}/_forcemerge?max_num_segments=1"

Note: Segment merging consumes CPU and a large number of I/O resources. Therefore, you are advised to perform segment merging during off-peak hours.

Any solutions will be appreciated!

Comment

You need to log in to comment to the post Login | Register
Comment

Notice: To protect the legitimate rights and interests of you, the community, and third parties, do not release content that may bring legal risks to all parties, including but are not limited to the following:
  • Politically sensitive content
  • Content concerning pornography, gambling, and drug abuse
  • Content that may disclose or infringe upon others ' commercial secrets, intellectual properties, including trade marks, copyrights, and patents, and personal privacy
Do not share your account and password with others. All operations performed using your account will be regarded as your own actions and all consequences arising therefrom will be borne by you. For details, see " User Agreement."

My Followers

Login and enjoy all the member benefits

Login

Block
Are you sure to block this user?
Users on your blacklist cannot comment on your post,cannot mention you, cannot send you private messages.
Reminder
Please bind your phone number to obtain invitation bonus.