diff --git a/src/box/vinyl.c b/src/box/vinyl.c index 9f9b4d029693c191e97d88f2c344e08a1fcad480..55a681049d0dc8a7f221720509257b1e9489eeae 100644 --- a/src/box/vinyl.c +++ b/src/box/vinyl.c @@ -3922,6 +3922,7 @@ vinyl_iterator_secondary_next(struct iterator *base, struct tuple **ret) assert(it->index->id > 0); struct tuple *tuple; +next: if (it->tx == NULL) { diag_set(ClientError, ER_CURSOR_NO_TRANSACTION); goto fail; @@ -3931,7 +3932,6 @@ vinyl_iterator_secondary_next(struct iterator *base, struct tuple **ret) goto fail; } - if (vy_read_iterator_next(&it->iterator, &tuple) != 0) goto fail; @@ -3954,11 +3954,26 @@ vinyl_iterator_secondary_next(struct iterator *base, struct tuple **ret) * Note, there's no need in vy_tx_track() as the * tuple is already tracked in the secondary index. */ + struct tuple *full_tuple; if (vy_point_lookup(it->index->pk, it->tx, vy_tx_read_view(it->tx), - tuple, &tuple) != 0) + tuple, &full_tuple) != 0) goto fail; - *ret = tuple_bless(tuple); - tuple_unref(tuple); + if (full_tuple == NULL) { + /* + * All indexes of a space must be consistent, i.e. + * if a tuple is present in one index, it must be + * present in all other indexes as well, so we can + * get here only if there's a bug somewhere in vinyl. + * Don't abort as core dump won't really help us in + * this case. Just warn the user and proceed to the + * next tuple. + */ + say_warn("%s: key %s missing in primary index", + vy_index_name(it->index), vy_stmt_str(tuple)); + goto next; + } + *ret = tuple_bless(full_tuple); + tuple_unref(full_tuple); if (*ret != NULL) return 0; fail: