Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use lucene directory abstraction to compute file size #649

Merged
merged 4 commits into from
Sep 9, 2023

Conversation

vthacker
Copy link
Contributor

@vthacker vthacker commented Aug 21, 2023

Summary

When we use the regular file abstractions to calculate the size of the lucene index, lucene might be merging segments. This means the function has a race condition between the time it fetches the list and the time the calculation is done.

This is harmless in practice as we just try again and keep the old value. But it leads to noisy logs. When we use Lucene's FS abstraction it has a list of pendingDeletes which helps avoid this race condition.

Another advantage of this PR is during the happy case i.e when the java file abstraction computes the size it can take the pending deletes into account. So the disk size is smaller than what we want to. This will address that problem as well as noted by Bryan

@vthacker vthacker force-pushed the vthacker_NoSuchFileException branch from 14eda48 to 530cb6a Compare August 21, 2023 10:40
@github-actions

This comment was marked as off-topic.

@vthacker vthacker changed the title use lucene file directory abstraction Use lucene directory abstraction to compute file size Aug 21, 2023
@vthacker vthacker marked this pull request as ready for review August 21, 2023 14:50
@vthacker vthacker force-pushed the vthacker_NoSuchFileException branch from 530cb6a to 0ec848a Compare August 22, 2023 09:41
Copy link
Contributor

@bryanlb bryanlb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good - we should update the PR description with content about motivation on this PR.

Let's go ahead and add a test for this as well - if we make the calculateDirectorySize() static we only need to pass in a FSDirectory, which we can use Mockito to stub out the two methods in question (listAll, fileLength)

@bryanlb
Copy link
Contributor

bryanlb commented Sep 8, 2023

This should help quite a bit on getting more consistent chunk sizes - it looks like by the time we go to close a chunk the size can vary quite a bit. This is the size as seen by the cache node when downloading them:

bash-4.2# du --max-depth=1 -h /tmp
12G	/tmp/kaldb-slot-log_1694133688_d2e4d14b-4575-49a4-a861-cb96ebe3f11c-e4ac2e4a-a21a-414b-ad5c-857f70e92ea6
12G	/tmp/kaldb-slot-log_1694189486_3c254df1-5f93-4269-9e5c-3d418ba73c83-19a370eb-0228-45ad-865e-8600129d850c
12G	/tmp/kaldb-slot-log_1694130606_7a12f57f-b226-49b0-9d24-eba8e4d429cb-bea4d75b-8c48-47f2-a8e0-7cf1cc24f9d4
8.5G	/tmp/kaldb-slot-log_1694126554_54b87114-de5f-4e46-b9ab-1a4386d1c170-b5c6cbf3-7246-4ad3-8861-d12db4fa0280
8.5G	/tmp/kaldb-slot-log_1694116620_f858944c-2393-42ea-964e-2130eeb49c05-761daf01-62c2-47c0-9d57-a04b400e2607
8.2G	/tmp/kaldb-slot-log_1694157164_e8ebe081-99e0-40e7-a950-cd788186b992-28003c45-0d62-46fc-a54f-104bc2366e63
11G	/tmp/kaldb-slot-log_1694182949_fb17a38e-764c-43b1-8a65-a18e9d3f9653-f9bf5ca6-0786-41dd-86de-15deab37ae3c
11G	/tmp/kaldb-slot-log_1694192263_2e632d3c-7540-4415-bace-44f517646545-29c6cbb8-dae2-42d4-a6a4-3d31677f69f6
8.9G	/tmp/kaldb-slot-log_1694093722_56a55809-5df7-4f91-988e-c49ce9708375-fc5e4459-a4e8-4ec2-8aa1-27269badfae3
12G	/tmp/kaldb-slot-log_1694155881_03280ecf-c65f-4f97-83ca-11dece422449-91a206f5-7b5c-4d6c-915c-f745f7497e91
8.7G	/tmp/kaldb-slot-log_1694123502_cca29cae-fd93-447b-b1d9-2569b2eabdbd-5c8c875d-15cb-4067-a940-b0a59f3f480c
12G	/tmp/kaldb-slot-log_1694140533_eae4d50e-44e5-4601-9805-85ca8aa4f07b-9a7fccc1-0dd3-4949-9db3-1f1a920fb823
8.9G	/tmp/kaldb-slot-log_1694174997_2c37b749-e7ab-4254-a077-03874f7dfc4e-a95549eb-f7ea-4cc7-9bba-3bd5acc50b22
13G	/tmp/kaldb-slot-log_1694165752_96c72ee5-94e0-4cdf-a283-67332920bfae-e0b69ed2-948d-4025-ac0e-cf4b5b715522
12G	/tmp/kaldb-slot-log_1694137391_cb00ecd8-5b2e-4024-aa07-1118c28c18d4-3efca108-d9d1-4814-96e0-a30b8432648b
8.5G	/tmp/kaldb-slot-log_1694106443_9a0bda21-50bc-4354-a23f-d1bae42a2670-02fce2d8-e6ee-4109-83f5-e08a8ec947cc
8.9G	/tmp/kaldb-slot-log_1694163548_0eb9bd5e-9e18-41f7-8021-d761a579b4f5-88015f01-0b4b-4317-832e-a742c4ec9107
12G	/tmp/kaldb-slot-log_1694139456_ca6e1d76-7b6d-4abc-8aad-04ed0e1db92c-f0114f59-84a2-4f0d-8074-cad772ccfdab
11G	/tmp/kaldb-slot-log_1694099688_5e718b9d-51df-427d-ba68-366d57d43cb8-1f660419-252e-48ed-b570-f7cfe7834dfb
8.6G	/tmp/kaldb-slot-log_1694175250_fbeda137-8707-4340-88c5-ab26fbba87f6-9ba2549c-3964-4036-837d-1b9531415fcf
11G	/tmp/kaldb-slot-log_1694103536_dd8c02bd-c0c2-4ff2-b455-286a266eda25-55c520a8-a103-40a5-a9a9-e09183ac4a17
7.7G	/tmp/kaldb-slot-log_1694155435_cf739a54-9d2d-43c1-b0c8-419d89017493-09ed0f4b-2981-428a-b379-7b5a9548b81c
12G	/tmp/kaldb-slot-log_1694150685_6dc144b8-929e-43e6-ba04-ef3aca5287c3-dfec085a-02c7-4d8f-a59f-b82e89f18fa4
8.7G	/tmp/kaldb-slot-log_1694115322_b0aea797-85f9-488d-bcc0-f05453c53ded-90ec0178-9937-47d3-9923-d1ec842e1544
8.0G	/tmp/kaldb-slot-log_1694161277_91f4707c-7f76-4367-8924-dfb7c997622b-f744104f-f24d-45aa-8dd5-b682b7938c9a
12G	/tmp/kaldb-slot-log_1694129204_67b33646-07ce-4354-b79a-873928e7ed80-0569723c-2ab6-4b17-aa1a-fea949a9246f
12G	/tmp/kaldb-slot-log_1694078041_4f789321-b28e-4840-8865-9fe893d9fae8-396ec04b-29a3-4a97-9334-82feaca20228
12G	/tmp/kaldb-slot-log_1694112655_8538af76-9bfe-4e4d-b4f7-f5ff78040d08-4b14ae40-0bdb-4bf5-80d0-c440319a6932
12G	/tmp/kaldb-slot-log_1694188297_0318e469-a644-45ac-9425-0532e2d43842-fb3cd260-f5c2-470e-844f-f7cc18bb0df4
12G	/tmp/kaldb-slot-log_1694140849_8265a47f-b864-40ad-94b3-58236aab0720-9ce8c8d8-974f-4a86-8e1c-76c34168ea26
8.7G	/tmp/kaldb-slot-log_1694115222_eb0d0056-7289-485d-8305-95ec48e67e39-0b31e32d-8702-467d-b269-7ef1eb7b3a8d
7.9G	/tmp/kaldb-slot-log_1694170658_b4bf38a5-4f9b-4966-b19d-e9eef29276ea-8e10a3df-a445-484a-8af3-5f2cb05345e3
790M	/tmp/kaldb-slot-log_1694184850_bb2bca0c-63af-4c44-b787-8a79ee5815b8-1ded5b36-e740-434e-a9b0-bb089a901542
12G	/tmp/kaldb-slot-log_1694166893_a02738a3-9d4b-48d6-9577-411bc1af937a-01974afa-e65b-46af-b862-7838e0b80247
8.8G	/tmp/kaldb-slot-log_1694115888_4fe0a737-deb7-4632-8041-5ba860e5624f-3be130f1-79c0-439b-bc03-1e79c425bbbc
12G	/tmp/kaldb-slot-log_1694157825_11f5ef85-e05c-4b02-a41f-78b24aad4c4d-9681be2f-4482-407e-8422-f33a28059da4
12G	/tmp/kaldb-slot-log_1694135666_7cd659d7-5234-47b0-90cd-04a01e3a7c92-fc0620c4-8a4d-4bb3-bf95-f7c24dfa370a
8.7G	/tmp/kaldb-slot-log_1694179239_ba994b8b-a1ba-4d9d-ba19-17414096f209-cdc8bd3b-b07a-4ebc-9e34-22dd84a44bcf
12G	/tmp/kaldb-slot-log_1694145713_2c7531e6-20ad-4326-9b38-ef4a06f5abf4-a62f34d3-7d18-4600-8423-639a5c075391
11G	/tmp/kaldb-slot-log_1694107031_234bfdc8-e2dc-4b95-8ce5-092ba3283f51-977e7a90-90ee-475b-bb88-d950e88c2d0d
9.3G	/tmp/kaldb-slot-log_1694098845_af03261d-7cdc-4b7d-b46c-6e70e51fb6af-90841942-51d6-4b31-89a2-67020ac6b8ec
13G	/tmp/kaldb-slot-log_1694179683_d442a624-6cd9-498c-9fbc-1496449b548d-74940822-c7ca-4802-99b2-f39e40fd93f6
12G	/tmp/kaldb-slot-log_1694126214_3c4ff4d9-fb9a-4be1-ab99-589679f37c47-3693c4ad-30ce-4dad-9b05-4e316939918f
12G	/tmp/kaldb-slot-log_1694080549_5a0a5958-3419-4e43-9612-4eb3900c7d47-14683cfe-8763-421d-b187-4f601334d023
11G	/tmp/kaldb-slot-log_1694111153_9375df2a-5d01-49d7-b05e-d16dd3518152-537dae37-1a52-4939-b6ad-b67c3d0bc6c0
12G	/tmp/kaldb-slot-log_1694097571_b69ae9e0-324c-44cc-aaf0-29acf31bb1f2-b27ca52a-5a55-4405-8aca-3b9c73d176d8
4.7G	/tmp/kaldb-slot-log_1694146246_721d6452-8af5-4490-8319-3d413590c0a0-b9c8a7b6-7417-484b-991e-7106594f8973
12G	/tmp/kaldb-slot-log_1694133416_95d3a7f6-896b-4a02-9b5e-9b5b1f26279b-248ae2c8-b2ae-4d6f-8363-c330ebe1269c
11G	/tmp/kaldb-slot-log_1694160502_e640c14e-b292-4814-b9c4-a30174fc660e-ce9b4104-a02f-4bab-ab03-c44e08ed3c07
3.7G	/tmp/kaldb-slot-log_1694090424_9ede4d42-00ca-46ca-abc6-f16dc308400c-c29fc669-9fbe-4da4-814f-33c47eff1350
9.3G	/tmp/kaldb-slot-log_1694116555_5110f939-8f19-422b-a6d9-f4449fbca0fa-fe3dc177-fafb-4216-ab67-13e0e7835c7a
12G	/tmp/kaldb-slot-log_1694155403_4312626b-cb74-4eac-b9c6-78a11cbf31e0-04b0596d-d0e0-45fc-97f3-fa7ceb57647b
12G	/tmp/kaldb-slot-log_1694163503_f499675a-1ed6-4f66-be71-80e0b807be12-42625760-e48a-41b0-abee-07523b57dce8
12G	/tmp/kaldb-slot-log_1694082798_c498071b-fcb6-4741-8f76-39a0390b86a4-f249fd3e-b13f-476d-ac1a-180405fc4c47
...
2.2T	/tmp

@vthacker vthacker force-pushed the vthacker_NoSuchFileException branch from 0ec848a to 26007d3 Compare September 8, 2023 21:41
@vthacker vthacker merged commit 6617042 into master Sep 9, 2023
@vthacker vthacker deleted the vthacker_NoSuchFileException branch September 9, 2023 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants