• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tarantool / tarantool / 11795789287

12 Nov 2024 10:44AM CUT coverage: 87.243% (-0.03%) from 87.277%
11795789287

push

github

locker
test: reduce dump count in vinyl-luatest/select_consistency_test

The test expects at least 10 dumps to be created in 60 seconds. It
usually works but sometimes, when the host is heavy loaded, Vinyl
doesn't produce enough dumps in time and fails the test. On CI the test
usually fails with 7-9 dumps. To avoid flaky failures, let's reduce the
expected dump count down to 5.

Closes #10752

NO_DOC=test fix
NO_CHANGELOG=test fix

(cherry picked from commit 5325abd34)

68506 of 121748 branches covered (56.27%)

101115 of 115901 relevant lines covered (87.24%)

2831017.15 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.51
/src/box/engine.c
1
/*
2
 * Copyright 2010-2016, Tarantool AUTHORS, please see AUTHORS file.
3
 *
4
 * Redistribution and use in source and binary forms, with or
5
 * without modification, are permitted provided that the following
6
 * conditions are met:
7
 *
8
 * 1. Redistributions of source code must retain the above
9
 *    copyright notice, this list of conditions and the
10
 *    following disclaimer.
11
 *
12
 * 2. Redistributions in binary form must reproduce the above
13
 *    copyright notice, this list of conditions and the following
14
 *    disclaimer in the documentation and/or other materials
15
 *    provided with the distribution.
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND
18
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
21
 * <COPYRIGHT HOLDER> OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
25
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
28
 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29
 * SUCH DAMAGE.
30
 */
31
#include "engine.h"
32

33
#include <stdbool.h>
34
#include <stddef.h>
35
#include <string.h>
36

37
#include "errinj.h"
38
#include "fiber.h"
39
#include "small/rlist.h"
40

41
RLIST_HEAD(engines);
42

43
enum recovery_state recovery_state = RECOVERY_NOT_STARTED;
44

45
/** Register engine instance. */
46
void engine_register(struct engine *engine)
20,655✔
47
{
48
        static int n_engines;
49
        rlist_add_tail_entry(&engines, engine, link);
20,655✔
50
        engine->id = n_engines++;
20,655✔
51
}
20,655✔
52

53
/** Find engine by name. */
54
struct engine *
55
engine_by_name(const char *name)
1,019,990✔
56
{
57
        struct engine *e;
58
        engine_foreach(e) {
1,972,170✔
59
                if (strcmp(e->name, name) == 0)
1,496,000✔
60
                        return e;
1,019,900✔
61
        }
62
        return NULL;
85✔
63
}
64

65
void
66
engine_shutdown(void)
4,026✔
67
{
68
        struct engine *engine, *tmp;
69
        rlist_foreach_entry_safe(engine, &engines, link, tmp) {
44,286!
70
                engine->vtab->shutdown(engine);
20,130✔
71
        }
72
}
4,026✔
73

74
void
75
engine_free(void)
4,025✔
76
{
77
        struct engine *engine, *tmp;
78
        rlist_foreach_entry_safe(engine, &engines, link, tmp) {
44,275!
79
                engine->vtab->free(engine);
20,125✔
80
        }
81
}
4,025✔
82

83
void
84
engine_switch_to_ro(void)
2,551✔
85
{
86
        struct engine *engine;
87
        engine_foreach(engine)
28,061✔
88
                engine->vtab->switch_to_ro(engine);
12,755✔
89
}
2,551✔
90

91
int
92
engine_bootstrap(void)
2,658✔
93
{
94
        recovery_state = INITIAL_RECOVERY;
2,658✔
95
        struct engine *engine;
96
        engine_foreach(engine) {
29,222✔
97
                if (engine->vtab->bootstrap(engine) != 0)
13,284✔
98
                        return -1;
2✔
99
        }
100
        recovery_state = FINISHED_RECOVERY;
2,656✔
101
        return 0;
2,656✔
102
}
103

104
int
105
engine_begin_initial_recovery(const struct vclock *recovery_vclock)
1,448✔
106
{
107
        recovery_state = INITIAL_RECOVERY;
1,448✔
108
        struct engine *engine;
109
        engine_foreach(engine) {
15,928✔
110
                if (engine->vtab->begin_initial_recovery(engine,
7,240!
111
                                        recovery_vclock) != 0)
112
                        return -1;
×
113
        }
114
        return 0;
1,448✔
115
}
116

117
int
118
engine_begin_final_recovery(void)
1,429✔
119
{
120
        recovery_state = FINAL_RECOVERY;
1,429✔
121
        struct engine *engine;
122
        engine_foreach(engine) {
15,719✔
123
                if (engine->vtab->begin_final_recovery(engine) != 0)
7,145!
124
                        return -1;
×
125
        }
126
        return 0;
1,429✔
127
}
128

129
int
130
engine_begin_hot_standby(void)
4✔
131
{
132
        struct engine *engine;
133
        engine_foreach(engine) {
36✔
134
                if (engine->vtab->begin_hot_standby(engine) != 0)
17✔
135
                        return -1;
1✔
136
        }
137
        return 0;
3✔
138
}
139

140
int
141
engine_end_recovery(void)
1,420✔
142
{
143
        recovery_state = FINISHED_RECOVERY;
1,420✔
144
        /*
145
         * For all new spaces created after recovery is complete,
146
         * when the primary key is added, enable all keys.
147
         */
148
        struct engine *engine;
149
        engine_foreach(engine) {
15,610✔
150
                if (engine->vtab->end_recovery(engine) != 0)
7,096✔
151
                        return -1;
1✔
152
        }
153
        return 0;
1,419✔
154
}
155

156
int
157
engine_begin_checkpoint(bool is_scheduled)
4,523✔
158
{
159
        struct engine *engine;
160
        engine_foreach(engine) {
49,743✔
161
                if (engine->vtab->begin_checkpoint(engine, is_scheduled) < 0)
22,611✔
162
                        return -1;
1✔
163
        }
164
        return 0;
4,522✔
165
}
166

167
int
168
engine_commit_checkpoint(const struct vclock *vclock)
4,516✔
169
{
170
        struct engine *engine;
171
        engine_foreach(engine) {
49,468✔
172
                if (engine->vtab->wait_checkpoint(engine, vclock) < 0)
22,500✔
173
                        return -1;
24✔
174
        }
175
        engine_foreach(engine) {
49,402✔
176
                engine->vtab->commit_checkpoint(engine, vclock);
22,456✔
177
        }
178
        return 0;
4,491✔
179
}
180

181
void
182
engine_abort_checkpoint(void)
31✔
183
{
184
        struct engine *engine;
185
        engine_foreach(engine)
341✔
186
                engine->vtab->abort_checkpoint(engine);
155✔
187
}
31✔
188

189
void
190
engine_collect_garbage(const struct vclock *vclock)
742✔
191
{
192
        struct engine *engine;
193
        engine_foreach(engine)
8,162✔
194
                engine->vtab->collect_garbage(engine, vclock);
3,710✔
195
}
742✔
196

197
int
198
engine_backup(const struct vclock *vclock, engine_backup_cb cb, void *cb_arg)
11✔
199
{
200
        struct engine *engine;
201
        engine_foreach(engine) {
121✔
202
                if (engine->vtab->backup(engine, vclock, cb, cb_arg) < 0)
55!
203
                        return -1;
×
204
        }
205
        return 0;
11✔
206
}
207

208
int
209
engine_prepare_join(struct engine_join_ctx *ctx)
683✔
210
{
211
        ctx->data = xcalloc(MAX_ENGINE_COUNT, sizeof(void *));
683!
212
        struct engine *engine;
213
        engine_foreach(engine) {
7,513✔
214
                if (engine->vtab->prepare_join(engine, ctx) != 0)
3,415!
215
                        goto fail;
×
216
        }
217
        return 0;
683✔
218
fail:
×
219
        engine_complete_join(ctx);
×
220
        return -1;
×
221
}
222

223
int
224
engine_join(struct engine_join_ctx *ctx, struct xstream *stream)
683✔
225
{
226
        ERROR_INJECT_YIELD(ERRINJ_ENGINE_JOIN_DELAY);
1,315!
227

228
        struct engine *engine;
229
        engine_foreach(engine) {
7,505✔
230
                if (engine->vtab->join(engine, ctx, stream) != 0)
3,412✔
231
                        return -1;
1✔
232
        }
233
        return 0;
682✔
234
}
235

236
void
237
engine_complete_join(struct engine_join_ctx *ctx)
683✔
238
{
239
        struct engine *engine;
240
        engine_foreach(engine) {
7,513✔
241
                engine->vtab->complete_join(engine, ctx);
3,415✔
242
        }
243
        free(ctx->data);
683✔
244
}
683✔
245

246
void
247
engine_memory_stat(struct engine_memory_stat *stat)
68✔
248
{
249
        memset(stat, 0, sizeof(*stat));
68✔
250
        struct engine *engine;
251
        engine_foreach(engine)
748✔
252
                engine->vtab->memory_stat(engine, stat);
340✔
253
}
68✔
254

255
void
256
engine_reset_stat(void)
27✔
257
{
258
        struct engine *engine;
259
        engine_foreach(engine)
297✔
260
                engine->vtab->reset_stat(engine);
135✔
261
}
27✔
262

263
/* {{{ Virtual method stubs */
264

265
struct engine_read_view *
266
generic_engine_create_read_view(struct engine *engine,
×
267
                                const struct read_view_opts *opts)
268
{
269
        (void)engine;
270
        (void)opts;
271
        unreachable();
×
272
        return NULL;
273
}
274

275
int
276
generic_engine_prepare_join(struct engine *engine, struct engine_join_ctx *ctx)
2,049✔
277
{
278
        ctx->data[engine->id] = NULL;
2,049✔
279
        return 0;
2,049✔
280
}
281

282
int
283
generic_engine_join(struct engine *engine, struct engine_join_ctx *ctx,
2,046✔
284
                    struct xstream *stream)
285
{
286
        (void)engine;
287
        (void)ctx;
288
        (void)stream;
289
        return 0;
2,046✔
290
}
291

292
void
293
generic_engine_complete_join(struct engine *engine, struct engine_join_ctx *ctx)
2,049✔
294
{
295
        (void)engine;
296
        (void)ctx;
297
}
2,049✔
298

299
int
300
generic_engine_begin(struct engine *engine, struct txn *txn)
×
301
{
302
        (void)engine;
303
        (void)txn;
304
        return 0;
×
305
}
306

307
int
308
generic_engine_begin_statement(struct engine *engine, struct txn *txn)
16,062,500✔
309
{
310
        (void)engine;
311
        (void)txn;
312
        return 0;
16,062,500✔
313
}
314

315
int
316
generic_engine_prepare(struct engine *engine, struct txn *txn)
×
317
{
318
        (void)engine;
319
        (void)txn;
320
        return 0;
×
321
}
322

323
void
324
generic_engine_commit(struct engine *engine, struct txn *txn)
×
325
{
326
        (void)engine;
327
        (void)txn;
328
}
×
329

330
void
331
generic_engine_rollback_statement(struct engine *engine, struct txn *txn,
37✔
332
                                  struct txn_stmt *stmt)
333
{
334
        (void)engine;
335
        (void)txn;
336
        (void)stmt;
337
}
37✔
338

339
void
340
generic_engine_rollback(struct engine *engine, struct txn *txn)
17,738✔
341
{
342
        (void)engine;
343
        (void)txn;
344
}
17,738✔
345

346
void
347
generic_engine_switch_to_ro(struct engine *engine)
10,204✔
348
{
349
        (void)engine;
350
}
10,204✔
351

352
int
353
generic_engine_bootstrap(struct engine *engine)
7,968✔
354
{
355
        (void)engine;
356
        return 0;
7,968✔
357
}
358

359
int
360
generic_engine_begin_initial_recovery(struct engine *engine,
4,344✔
361
                                      const struct vclock *vclock)
362
{
363
        (void)engine;
364
        (void)vclock;
365
        return 0;
4,344✔
366
}
367

368
int
369
generic_engine_begin_final_recovery(struct engine *engine)
4,287✔
370
{
371
        (void)engine;
372
        return 0;
4,287✔
373
}
374

375
int
376
generic_engine_begin_hot_standby(struct engine *engine)
9✔
377
{
378
        (void)engine;
379
        return 0;
9✔
380
}
381

382
int
383
generic_engine_end_recovery(struct engine *engine)
4,257✔
384
{
385
        (void)engine;
386
        return 0;
4,257✔
387
}
388

389
int
390
generic_engine_begin_checkpoint(struct engine *engine, bool is_scheduled)
13,566✔
391
{
392
        (void)engine;
393
        (void)is_scheduled;
394
        return 0;
13,566✔
395
}
396

397
int
398
generic_engine_wait_checkpoint(struct engine *engine,
13,476✔
399
                               const struct vclock *vclock)
400
{
401
        (void)engine;
402
        (void)vclock;
403
        return 0;
13,476✔
404
}
405

406
void
407
generic_engine_commit_checkpoint(struct engine *engine,
13,473✔
408
                                 const struct vclock *vclock)
409
{
410
        (void)engine;
411
        (void)vclock;
412
}
13,473✔
413

414
void
415
generic_engine_abort_checkpoint(struct engine *engine)
93✔
416
{
417
        (void)engine;
418
}
93✔
419

420
void
421
generic_engine_collect_garbage(struct engine *engine,
2,226✔
422
                               const struct vclock *vclock)
423
{
424
        (void)engine;
425
        (void)vclock;
426
}
2,226✔
427

428
int
429
generic_engine_backup(struct engine *engine, const struct vclock *vclock,
33✔
430
                      engine_backup_cb cb, void *cb_arg)
431
{
432
        (void)engine;
433
        (void)vclock;
434
        (void)cb;
435
        (void)cb_arg;
436
        return 0;
33✔
437
}
438

439
void
440
generic_engine_memory_stat(struct engine *engine,
204✔
441
                           struct engine_memory_stat *stat)
442
{
443
        (void)engine;
444
        (void)stat;
445
}
204✔
446

447
void
448
generic_engine_reset_stat(struct engine *engine)
108✔
449
{
450
        (void)engine;
451
}
108✔
452

453
int
454
generic_engine_check_space_def(struct space_def *def)
185,783✔
455
{
456
        (void)def;
457
        return 0;
185,783✔
458
}
459

460
void
461
generic_engine_shutdown(struct engine *engine)
12,078✔
462
{
463
        (void)engine;
464
}
12,078✔
465

466
/* }}} */
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc