0

The elastic clone api (https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-clone-index.html) states

Cloning works as follows:

  • First, it creates a new target index with the same definition as the source index.
  • Then it hard-links segments from the source index into the target index. (If the file system doesn’t support hard-linking, then all segments are copied into the new index, which is a much more time consuming process.)
  • Finally, it recovers the target index as though it were a closed index which had just been re-opened.

If documents are hard-linked, what happens if I delete the old source index via the delete API?

  • Are the hard-linked segments copied to the new index data directory?
  • Is the data lost?
  • Are the hard-linked segments just kept in their original location on disk?
m_c
  • 59
  • 1
  • 9

1 Answers1

1

A hard link is a mirror copy of the original file, so

  1. Yes
  2. No, because it has been copied
  3. No, if you delete the old index, the original segments are gone, but since they have been copied into your new index, you're fine.

It's easy to test ;-)

Val
  • 207,596
  • 13
  • 358
  • 360
  • I did test this and it worked fine. However, I wasn't sure if the hard-linking part did happen or not. Another test on a clean system showed, that the segments on disk where indeed hard-linked and deleting the old index didn't affect the new index. – m_c Jul 21 '23 at 09:20
  • Awesome, glad it helped! – Val Jul 21 '23 at 09:29