Index / Delete API when causing auto index creation can cause buffer data overrun, closes #1122.

This commit is contained in:
kimchy 2011-07-14 03:04:58 +03:00
parent e98860dc29
commit 848638d53c
2 changed files with 8 additions and 6 deletions

View File

@ -71,24 +71,25 @@ public class TransportDeleteAction extends TransportShardReplicationOperationAct
return ThreadPool.Names.INDEX;
}
@Override protected void doExecute(final DeleteRequest deleteRequest, final ActionListener<DeleteResponse> listener) {
if (autoCreateIndex && !clusterService.state().metaData().hasConcreteIndex(deleteRequest.index())) {
createIndexAction.execute(new CreateIndexRequest(deleteRequest.index()), new ActionListener<CreateIndexResponse>() {
@Override protected void doExecute(final DeleteRequest request, final ActionListener<DeleteResponse> listener) {
if (autoCreateIndex && !clusterService.state().metaData().hasConcreteIndex(request.index())) {
request.beforeLocalFork();
createIndexAction.execute(new CreateIndexRequest(request.index()), new ActionListener<CreateIndexResponse>() {
@Override public void onResponse(CreateIndexResponse result) {
innerExecute(deleteRequest, listener);
innerExecute(request, listener);
}
@Override public void onFailure(Throwable e) {
if (ExceptionsHelper.unwrapCause(e) instanceof IndexAlreadyExistsException) {
// we have the index, do it
innerExecute(deleteRequest, listener);
innerExecute(request, listener);
} else {
listener.onFailure(e);
}
}
});
} else {
innerExecute(deleteRequest, listener);
innerExecute(request, listener);
}
}

View File

@ -99,6 +99,7 @@ public class TransportIndexAction extends TransportShardReplicationOperationActi
}
}
if (autoCreateIndex && !clusterService.state().metaData().hasConcreteIndex(request.index())) {
request.beforeLocalFork(); // we fork on another thread...
createIndexAction.execute(new CreateIndexRequest(request.index()).cause("auto(index api)"), new ActionListener<CreateIndexResponse>() {
@Override public void onResponse(CreateIndexResponse result) {
innerExecute(request, listener);