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

Do not let index not found errors prevent other objects from being va… #58

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
5.0.0a3 (unreleased)
--------------------

- Nothing changed yet.
- Do not let index not found errors prevent other objects from being vacuumed
[vangheem]


5.0.0a2 (2019-06-21)
Expand Down
45 changes: 27 additions & 18 deletions guillotina_elasticsearch/commands/vacuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import aioelasticsearch
import asyncio
import elasticsearch
import json
import logging

Expand Down Expand Up @@ -92,14 +93,17 @@ async def iter_batched_es_keys(self):
indexes.append(index['index'])

for index_name in indexes:
result = await self.conn.search(
index=index_name,
scroll='15m',
size=PAGE_SIZE,
_source=False,
body={
"sort": ["_doc"]
})
try:
result = await self.conn.search(
index=index_name,
scroll='15m',
size=PAGE_SIZE,
_source=False,
body={
"sort": ["_doc"]
})
except elasticsearch.exceptions.NotFoundError:
continue
yield [r['_id'] for r in result['hits']['hits']], index_name
scroll_id = result['_scroll_id']
while scroll_id:
Expand Down Expand Up @@ -299,17 +303,22 @@ async def check_missing(self):
async for batch in self.iter_paged_db_keys([self.container.__uuid__]):
oids = [r['zoid'] for r in batch]
indexes = self.get_indexes_for_oids(oids)
results = await self.conn.search(
','.join(indexes), body={
'query': {
'terms': {
'uuid': oids
try:
results = await self.conn.search(
','.join(indexes), body={
'query': {
'terms': {
'uuid': oids
}
}
}
},
_source=False,
stored_fields='tid,parent_uuid',
size=PAGE_SIZE)
},
_source=False,
stored_fields='tid,parent_uuid',
size=PAGE_SIZE)
except elasticsearch.exceptions.NotFoundError:
logger.warning(
f'Error searching index: {indexes}', exc_info=True)
continue

es_batch = {}
for result in results['hits']['hits']:
Expand Down