| 1 | /* |
| 2 | Copyright (C) 2021-2024 Sutou Kouhei <[email protected]> |
| 3 | |
| 4 | This library is free software; you can redistribute it and/or |
| 5 | modify it under the terms of the GNU Lesser General Public |
| 6 | License as published by the Free Software Foundation; either |
| 7 | version 2.1 of the License, or (at your option) any later version. |
| 8 | |
| 9 | This library is distributed in the hope that it will be useful, |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | Lesser General Public License for more details. |
| 13 | |
| 14 | You should have received a copy of the GNU Lesser General Public |
| 15 | License along with this library; if not, write to the Free Software |
| 16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 17 | */ |
| 18 | |
| 19 | #include "grn_ctx.hpp"cxx . . $ `<file>/lib/grn_ctx.hpp`/ |
| 20 | #include "grn_ctx_impl.h"cxx . . $ `<file>/lib/grn_ctx_impl.h`/ |
| 21 | #include "grn_dat.h"cxx . . $ `<file>/lib/grn_dat.h`/ |
| 22 | #include "grn_db.h"cxx . . $ `<file>/lib/grn_db.h`/ |
| 23 | #include "grn_ii.h"cxx . . $ `<file>/lib/grn_ii.h`/ |
| 24 | #include "grn_obj.h"cxx . . $ `<file>/lib/grn_obj.h`/ |
| 25 | #include "grn_pat.h"cxx . . $ `<file>/lib/grn_pat.h`/ |
| 26 | #include "grn_store.h"cxx . . $ `<file>/lib/grn_store.h`/ |
| 27 | #include "grn_table.h"cxx . . $ `<file>/lib/grn_table.h`/ |
| 28 | #include "grn_task_executor.hpp"cxx . . $ `<file>/lib/grn_task_executor.hpp`/ |
| 29 | #include "grn_wal.h"cxx . . $ `<file>/lib/grn_wal.h`/ |
| 30 | |
| 31 | #include <utility> |
| 32 | #include <vector> |
| 33 | |
| 34 | static const char *grn_db_wal_recover_tagcxx . . $ grn_db_wal_recover_tag. = "[db][wal][recover]"; |
| 35 | |
| 36 | static void |
| 37 | grn_db_wal_recover_ensure_remove_by_idcxx . . $ grn_db_wal_recover_ensure_remove_by_id(39c852cb5629a360).(grn_ctx *ctx, grn_db *db, grn_id id) |
| 38 | { |
| 39 | if (grn_table_at(ctx, db->keyscxx . . $ _grn_db#keys., id) != id) { |
| 40 | return; |
| 41 | } |
| 42 | |
| 43 | grn_ctx_remove_by_id(ctx, |
| 44 | id, |
| 45 | GRN_OBJ_REMOVE_DEPENDENTcxx . . $ `include/groonga/groonga.h:1516:9`! | GRN_OBJ_REMOVE_ENSUREcxx . . $ `include/groonga/groonga.h:1517:9`!); |
| 46 | } |
| 47 | |
| 48 | static void |
| 49 | grn_db_wal_recover_remove_objectcxx . . $ grn_db_wal_recover_remove_object(f492fda562814758).(grn_ctx *ctx, |
| 50 | grn_db *db, |
| 51 | grn_obj *object, |
| 52 | grn_id id) |
| 53 | { |
| 54 | if (object) { |
| 55 | if (id == GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!) { |
| 56 | id = DB_OBJcxx . . $ `lib/grn_db.h:62:9`!(object)->id; |
| 57 | } |
| 58 | grn_obj_clear_lock(ctx, object); |
| 59 | grn_obj_remove_flags(ctx, |
| 60 | object, |
| 61 | GRN_OBJ_REMOVE_DEPENDENTcxx . . $ `include/groonga/groonga.h:1516:9`! | GRN_OBJ_REMOVE_ENSUREcxx . . $ `include/groonga/groonga.h:1517:9`!); |
| 62 | } |
| 63 | grn_db_wal_recover_ensure_remove_by_idcxx . . $ grn_db_wal_recover_ensure_remove_by_id(39c852cb5629a360).(ctx, db, id); |
| 64 | } |
| 65 | |
| 66 | static void |
| 67 | grn_db_wal_recover_keyscxx . . $ grn_db_wal_recover_keys(ea3523c40d20cded).(grn_ctx *ctx, grn_db *db) |
| 68 | { |
| 69 | const char *tag = grn_db_wal_recover_tagcxx . . $ grn_db_wal_recover_tag.; |
| 70 | const char *placeholder_prefix = "_PLACEHOLDER_"; |
| 71 | |
| 72 | GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, GRN_LOG_NOTICE, "%s rebuild broken DB keys", tag); |
| 73 | |
| 74 | bool success = false; |
| 75 | |
| 76 | grn_obj path; |
| 77 | GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&path, 0); |
| 78 | GRN_TEXT_SETScxx . . $ `include/groonga/groonga.h:2783:9`!(ctx, &path, grn_io_path(grn_obj_get_io(ctx, db->keys))); |
| 79 | GRN_TEXT_PUTCcxx . . $ `include/groonga/groonga.h:2775:9`!(ctx, &path, '\0'); |
| 80 | grn_obj recovering_path; |
| 81 | GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&recovering_path, 0); |
| 82 | GRN_TEXT_PUTScxx . . $ `include/groonga/groonga.h:2781:9`!(ctx, &recovering_path, GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&path)); |
| 83 | GRN_TEXT_PUTScxx . . $ `include/groonga/groonga.h:2781:9`!(ctx, &recovering_path, ".recovering"); |
| 84 | GRN_TEXT_PUTCcxx . . $ `include/groonga/groonga.h:2775:9`!(ctx, &recovering_path, '\0'); |
| 85 | grn_obj broken_path; |
| 86 | GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&broken_path, 0); |
| 87 | GRN_TEXT_PUTScxx . . $ `include/groonga/groonga.h:2781:9`!(ctx, &broken_path, GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&path)); |
| 88 | GRN_TEXT_PUTScxx . . $ `include/groonga/groonga.h:2781:9`!(ctx, &broken_path, ".broken"); |
| 89 | GRN_TEXT_PUTCcxx . . $ `include/groonga/groonga.h:2775:9`!(ctx, &broken_path, '\0'); |
| 90 | |
| 91 | grn_io_remove_if_exist(ctx, GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&recovering_path)); |
| 92 | bool use_pat = (db->keyscxx . . $ _grn_db#keys.->headercxx . . $ _grn_obj#header..type == GRN_TABLE_PAT_KEYcxx . . $ `include/groonga/groonga.h:896:9`!); |
| 93 | grn_obj *new_keys = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!; |
| 94 | if (use_pat) { |
| 95 | new_keys = (grn_obj *)grn_pat_create(ctx, |
| 96 | GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&recovering_path), |
| 97 | GRN_TABLE_MAX_KEY_SIZEcxx . . $ `include/groonga/table.h:26:9`!, |
| 98 | 0, |
| 99 | GRN_OBJ_KEY_VAR_SIZEcxx . . $ `include/groonga/groonga.h:820:9`!); |
| 100 | } else { |
| 101 | new_keys = (grn_obj *)grn_dat_create(ctx, |
| 102 | GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&recovering_path), |
| 103 | GRN_TABLE_MAX_KEY_SIZEcxx . . $ `include/groonga/table.h:26:9`!, |
| 104 | 0, |
| 105 | GRN_OBJ_KEY_VAR_SIZEcxx . . $ `include/groonga/groonga.h:820:9`!); |
| 106 | } |
| 107 | if (!new_keys) { |
| 108 | goto exit; |
| 109 | } |
| 110 | |
| 111 | { |
| 112 | grn_obj placeholder_key; |
| 113 | GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&placeholder_key, 0); |
| 114 | grn_id previous_id = GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!; |
| 115 | GRN_TABLE_EACH_BEGIN_FLAGScxx . . $ `include/groonga/table.h:631:9`!(ctx, |
| 116 | db->keys, |
| 117 | cursor, |
| 118 | id, |
| 119 | GRN_CURSOR_BY_IDcxx . . $ `include/groonga/table.h:280:9`! | GRN_CURSOR_ASCENDINGcxx . . $ `include/groonga/table.h:273:9`!) |
| 120 | { |
| 121 | for (; previous_id < id - 1; previous_id++) { |
| 122 | GRN_BULK_REWINDcxx . . $ `include/groonga/groonga.h:2599:9`!(&placeholder_key); |
| 123 | grn_text_printf(ctx, |
| 124 | &placeholder_key, |
| 125 | "%s%u", |
| 126 | placeholder_prefix, |
| 127 | previous_id + 1); |
| 128 | grn_id placeholder_id; |
| 129 | if (use_pat) { |
| 130 | placeholder_id = grn_pat_add(ctx, |
| 131 | (grn_pat *)new_keys, |
| 132 | GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&placeholder_key), |
| 133 | GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&placeholder_key), |
| 134 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!, |
| 135 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!); |
| 136 | } else { |
| 137 | placeholder_id = grn_dat_add(ctx, |
| 138 | (grn_dat *)new_keys, |
| 139 | GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&placeholder_key), |
| 140 | GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&placeholder_key), |
| 141 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!, |
| 142 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!); |
| 143 | } |
| 144 | if (placeholder_id != previous_id + 1) { |
| 145 | ERRcxx . . $ `lib/grn_error.h:156:9`!(GRN_UNKNOWN_ERROR, |
| 146 | "%s failed to assign ID for deleted object: " |
| 147 | "assigned:%u " |
| 148 | "expected:%u", |
| 149 | tag, |
| 150 | placeholder_id, |
| 151 | previous_id + 1); |
| 152 | break; |
| 153 | } |
| 154 | } |
| 155 | if (ctx->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESS) { |
| 156 | break; |
| 157 | } |
| 158 | void *key; |
| 159 | int key_size = grn_table_cursor_get_key(ctx, cursor, &key); |
| 160 | grn_id added_id; |
| 161 | if (new_keys->headercxx . . $ _grn_obj#header..type == GRN_TABLE_PAT_KEYcxx . . $ `include/groonga/groonga.h:896:9`!) { |
| 162 | added_id = |
| 163 | grn_pat_add(ctx, (grn_pat *)new_keys, key, key_size, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!); |
| 164 | } else { |
| 165 | added_id = |
| 166 | grn_dat_add(ctx, (grn_dat *)new_keys, key, key_size, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!); |
| 167 | } |
| 168 | if (added_id != id) { |
| 169 | ERRcxx . . $ `lib/grn_error.h:156:9`!(GRN_UNKNOWN_ERROR, |
| 170 | "%s failed to assign expected ID: " |
| 171 | "name:<%.*s> " |
| 172 | "assigned:%u " |
| 173 | "expected:%u", |
| 174 | tag, |
| 175 | key_size, |
| 176 | (const char *)key, |
| 177 | added_id, |
| 178 | id); |
| 179 | break; |
| 180 | } |
| 181 | previous_id = id; |
| 182 | } |
| 183 | GRN_TABLE_EACH_ENDcxx . . $ `include/groonga/table.h:665:9`!(ctx, cursor); |
| 184 | GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &placeholder_key); |
| 185 | } |
| 186 | if (ctx->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESS) { |
| 187 | goto exit; |
| 188 | } |
| 189 | |
| 190 | GRN_TABLE_EACH_BEGIN_MINcxx . . $ `include/groonga/table.h:648:9`!(ctx, |
| 191 | new_keys, |
| 192 | cursor, |
| 193 | id, |
| 194 | placeholder_prefix, |
| 195 | strlen(placeholder_prefix), |
| 196 | GRN_CURSOR_PREFIXcxx . . $ `include/groonga/table.h:281:9`!) |
| 197 | { |
| 198 | grn_table_cursor_delete(ctx, cursor); |
| 199 | } |
| 200 | GRN_TABLE_EACH_ENDcxx . . $ `include/groonga/table.h:665:9`!(ctx, cursor); |
| 201 | |
| 202 | grn_obj_close(ctx, new_keys); |
| 203 | new_keys = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!; |
| 204 | grn_obj_close(ctx, db->keyscxx . . $ _grn_db#keys.); |
| 205 | |
| 206 | grn_io_remove_if_exist(ctx, GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&broken_path)); |
| 207 | grn_io_rename(ctx, GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&path), GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&broken_path)); |
| 208 | if (ctx->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESS) { |
| 209 | goto exit; |
| 210 | } |
| 211 | grn_io_rename(ctx, GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&recovering_path), GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&path)); |
| 212 | if (ctx->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESS) { |
| 213 | ERRCLRcxx . . $ `lib/grn_error.h:37:9`!(ctx); |
| 214 | grn_io_remove_if_exist(ctx, GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&path)); |
| 215 | grn_io_rename(ctx, GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&broken_path), GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&path)); |
| 216 | ERRcxx . . $ `lib/grn_error.h:156:9`!(GRN_UNKNOWN_ERROR, |
| 217 | "%s failed to rename files of rebuilt DB keys: <%s>", |
| 218 | tag, |
| 219 | GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&recovering_path)); |
| 220 | goto exit; |
| 221 | } |
| 222 | if (use_pat) { |
| 223 | db->keyscxx . . $ _grn_db#keys. = (grn_obj *)grn_pat_open(ctx, GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&path)); |
| 224 | } else { |
| 225 | db->keyscxx . . $ _grn_db#keys. = (grn_obj *)grn_dat_open(ctx, GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&path)); |
| 226 | } |
| 227 | if (!db->keyscxx . . $ _grn_db#keys.) { |
| 228 | ERRCLRcxx . . $ `lib/grn_error.h:37:9`!(ctx); |
| 229 | grn_io_remove_if_exist(ctx, GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&path)); |
| 230 | grn_io_rename(ctx, GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&broken_path), GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&path)); |
| 231 | ERRcxx . . $ `lib/grn_error.h:156:9`!(GRN_UNKNOWN_ERROR, |
| 232 | "%s failed to open rebuilt DB keys: <%s>", |
| 233 | tag, |
| 234 | GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&path)); |
| 235 | goto exit; |
| 236 | } |
| 237 | grn_io_remove(ctx, GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&broken_path)); |
| 238 | success = true; |
| 239 | GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, GRN_LOG_NOTICE, "%s succeeded to rebuild broken DB keys", tag); |
| 240 | |
| 241 | exit: |
| 242 | if (!success) { |
| 243 | GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, GRN_LOG_NOTICE, "%s failed to rebuild broken DB keys", tag); |
| 244 | } |
| 245 | if (new_keys) { |
| 246 | grn_obj_close(ctx, new_keys); |
| 247 | } |
| 248 | GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &path); |
| 249 | GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &recovering_path); |
| 250 | GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &broken_path); |
| 251 | } |
| 252 | |
| 253 | static grn_hash * |
| 254 | grn_broken_ids_opencxx . . $ grn_broken_ids_open(ffed87ac09259372).(grn_ctx *ctx) |
| 255 | { |
| 256 | return grn_hash_create(ctx, |
| 257 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!, |
| 258 | sizeof(grn_id), |
| 259 | 0, |
| 260 | GRN_OBJ_TABLE_HASH_KEYcxx . . $ `include/groonga/groonga.h:688:9`! | GRN_HASH_TINYcxx . . $ `include/groonga/hash.h:26:9`!); |
| 261 | } |
| 262 | |
| 263 | static void |
| 264 | grn_broken_ids_closecxx . . $ grn_broken_ids_close(57c8ed80822320b7).(grn_ctx *ctx, grn_hash *broken_ids) |
| 265 | { |
| 266 | grn_hash_close(ctx, broken_ids); |
| 267 | } |
| 268 | |
| 269 | static void |
| 270 | grn_broken_ids_addcxx . . $ grn_broken_ids_add(e1b55fed33f28ff6).(grn_ctx *ctx, grn_hash *broken_ids, grn_id id) |
| 271 | { |
| 272 | grn_hash_add(ctx, broken_ids, &id, sizeof(grn_id), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!); |
| 273 | } |
| 274 | |
| 275 | static bool |
| 276 | grn_broken_ids_existcxx . . $ grn_broken_ids_exist(2e9db3e2e67045d8).(grn_ctx *ctx, grn_hash *broken_ids, grn_id id) |
| 277 | { |
| 278 | return grn_hash_get(ctx, broken_ids, &id, sizeof(grn_id), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!) != GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!; |
| 279 | } |
| 280 | |
| 281 | static grn_id |
| 282 | grn_broken_ids_cursor_getcxx . . $ grn_broken_ids_cursor_get(6f2ad840d1580522).(grn_ctx *ctx, grn_hash_cursor *cursor) |
| 283 | { |
| 284 | void *key; |
| 285 | grn_hash_cursor_get_key(ctx, cursor, &key); |
| 286 | return *((grn_id *)key); |
| 287 | } |
| 288 | |
| 289 | static void |
| 290 | grn_db_wal_recover_collect_depended_object_idscxx . . $ grn_db_wal_recover_collect_depended_object_ids(4f8716b596106d6d).(grn_ctx *ctx, |
| 291 | grn_db *db, |
| 292 | grn_hash *broken_table_ids, |
| 293 | grn_hash *broken_column_ids) |
| 294 | { |
| 295 | GRN_TABLE_EACH_BEGIN_FLAGScxx . . $ `include/groonga/table.h:631:9`!(ctx, db->keys, cursor, id, GRN_CURSOR_BY_IDcxx . . $ `include/groonga/table.h:280:9`!) |
| 296 | { |
| 297 | if (grn_id_is_builtin(ctx, id)) { |
| 298 | continue; |
| 299 | } |
| 300 | if (grn_broken_ids_existcxx . . $ grn_broken_ids_exist(2e9db3e2e67045d8).(ctx, broken_table_ids, id)) { |
| 301 | continue; |
| 302 | } |
| 303 | if (grn_broken_ids_existcxx . . $ grn_broken_ids_exist(2e9db3e2e67045d8).(ctx, broken_column_ids, id)) { |
| 304 | continue; |
| 305 | } |
| 306 | |
| 307 | grn_ctx_push_temporary_open_space(ctx); |
| 308 | grn_obj *object = grn_ctx_at(ctx, id); |
| 309 | if (object) { |
| 310 | switch (object->headercxx . . $ _grn_obj#header..type) { |
| 311 | case GRN_TABLE_HASH_KEYcxx . . $ `include/groonga/groonga.h:895:9`!: |
| 312 | case GRN_TABLE_PAT_KEYcxx . . $ `include/groonga/groonga.h:896:9`!: |
| 313 | case GRN_TABLE_DAT_KEYcxx . . $ `include/groonga/groonga.h:897:9`!: |
| 314 | if (grn_broken_ids_existcxx . . $ grn_broken_ids_exist(2e9db3e2e67045d8).(ctx, |
| 315 | broken_table_ids, |
| 316 | object->headercxx . . $ _grn_obj#header..domain)) { |
| 317 | grn_broken_ids_addcxx . . $ grn_broken_ids_add(e1b55fed33f28ff6).(ctx, broken_table_ids, id); |
| 318 | } |
| 319 | break; |
| 320 | case GRN_COLUMN_FIX_SIZEcxx . . $ `include/groonga/groonga.h:900:9`!: |
| 321 | if (grn_broken_ids_existcxx . . $ grn_broken_ids_exist(2e9db3e2e67045d8).(ctx, |
| 322 | broken_table_ids, |
| 323 | DB_OBJcxx . . $ `lib/grn_db.h:62:9`!(object)->range)) { |
| 324 | grn_broken_ids_addcxx . . $ grn_broken_ids_add(e1b55fed33f28ff6).(ctx, broken_column_ids, id); |
| 325 | } |
| 326 | break; |
| 327 | case GRN_COLUMN_VAR_SIZEcxx . . $ `include/groonga/groonga.h:901:9`!: |
| 328 | if (grn_broken_ids_existcxx . . $ grn_broken_ids_exist(2e9db3e2e67045d8).(ctx, |
| 329 | broken_table_ids, |
| 330 | DB_OBJcxx . . $ `lib/grn_db.h:62:9`!(object)->range)) { |
| 331 | grn_broken_ids_addcxx . . $ grn_broken_ids_add(e1b55fed33f28ff6).(ctx, broken_column_ids, id); |
| 332 | } |
| 333 | { |
| 334 | grn_obj source_ids; |
| 335 | GRN_RECORD_INITcxx . . $ `include/groonga/groonga.h:2868:9`!(&source_ids, GRN_OBJ_VECTORcxx . . $ `include/groonga/groonga.h:2734:9`!, GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!); |
| 336 | grn_obj_get_info(ctx, object, GRN_INFO_SOURCE, &source_ids); |
| 337 | size_t n = GRN_RECORD_VECTOR_SIZEcxx . . $ `include/groonga/groonga.h:3264:9`!(&source_ids); |
| 338 | size_t i; |
| 339 | for (i = 0; i < n; i++) { |
| 340 | grn_id source_id = GRN_RECORD_VALUE_ATcxx . . $ `include/groonga/groonga.h:3148:9`!(&source_ids, i); |
| 341 | if (grn_broken_ids_existcxx . . $ grn_broken_ids_exist(2e9db3e2e67045d8).(ctx, broken_column_ids, source_id)) { |
| 342 | grn_broken_ids_addcxx . . $ grn_broken_ids_add(e1b55fed33f28ff6).(ctx, broken_column_ids, id); |
| 343 | } |
| 344 | } |
| 345 | GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &source_ids); |
| 346 | } |
| 347 | break; |
| 348 | case GRN_COLUMN_INDEXcxx . . $ `include/groonga/groonga.h:902:9`!: |
| 349 | if (grn_broken_ids_existcxx . . $ grn_broken_ids_exist(2e9db3e2e67045d8).(ctx, |
| 350 | broken_table_ids, |
| 351 | DB_OBJcxx . . $ `lib/grn_db.h:62:9`!(object)->range)) { |
| 352 | grn_broken_ids_addcxx . . $ grn_broken_ids_add(e1b55fed33f28ff6).(ctx, broken_column_ids, id); |
| 353 | } |
| 354 | { |
| 355 | grn_obj source_ids; |
| 356 | GRN_RECORD_INITcxx . . $ `include/groonga/groonga.h:2868:9`!(&source_ids, GRN_OBJ_VECTORcxx . . $ `include/groonga/groonga.h:2734:9`!, GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!); |
| 357 | grn_obj_get_info(ctx, object, GRN_INFO_SOURCE, &source_ids); |
| 358 | size_t n = GRN_RECORD_VECTOR_SIZEcxx . . $ `include/groonga/groonga.h:3264:9`!(&source_ids); |
| 359 | size_t i; |
| 360 | for (i = 0; i < n; i++) { |
| 361 | grn_id source_id = GRN_RECORD_VALUE_ATcxx . . $ `include/groonga/groonga.h:3148:9`!(&source_ids, i); |
| 362 | if (grn_broken_ids_existcxx . . $ grn_broken_ids_exist(2e9db3e2e67045d8).(ctx, broken_table_ids, source_id) || |
| 363 | grn_broken_ids_existcxx . . $ grn_broken_ids_exist(2e9db3e2e67045d8).(ctx, broken_column_ids, source_id)) { |
| 364 | grn_broken_ids_addcxx . . $ grn_broken_ids_add(e1b55fed33f28ff6).(ctx, broken_column_ids, id); |
| 365 | } |
| 366 | } |
| 367 | GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &source_ids); |
| 368 | } |
| 369 | break; |
| 370 | default: |
| 371 | break; |
| 372 | } |
| 373 | GRN_DB_WAL_DISABLE_WAL_BEGINcxx . . $ `lib/grn_db.h:771:9`!(ctx) { grn_obj_unref(ctx, object); } |
| 374 | GRN_DB_WAL_DISABLE_WAL_ENDcxx . . $ `lib/grn_db.h:776:9`!(ctx); |
| 375 | } |
| 376 | ERRCLRcxx . . $ `lib/grn_error.h:37:9`!(ctx); |
| 377 | GRN_DB_WAL_DISABLE_WAL_BEGINcxx . . $ `lib/grn_db.h:771:9`!(ctx) { grn_ctx_pop_temporary_open_space(ctx); } |
| 378 | GRN_DB_WAL_DISABLE_WAL_ENDcxx . . $ `lib/grn_db.h:776:9`!(ctx); |
| 379 | } |
| 380 | GRN_TABLE_EACH_ENDcxx . . $ `include/groonga/table.h:665:9`!(ctx, cursor); |
| 381 | } |
| 382 | |
| 383 | static void |
| 384 | grn_db_wal_recover_remove_duplicated_broken_column_idscxx . . $ grn_db_wal_recover_remove_duplicated_broken_column_ids(4f8716b596106d6d).( |
| 385 | grn_ctx *ctx, |
| 386 | grn_db *db, |
| 387 | grn_hash *broken_table_ids, |
| 388 | grn_hash *broken_column_ids) |
| 389 | { |
| 390 | GRN_HASH_EACH_BEGINcxx . . $ `include/groonga/hash.h:141:9`!(ctx, broken_column_ids, cursor, column_entry_id) |
| 391 | { |
| 392 | grn_ctx_push_temporary_open_space(ctx); |
| 393 | grn_id broken_column_id = grn_broken_ids_cursor_getcxx . . $ grn_broken_ids_cursor_get(6f2ad840d1580522).(ctx, cursor); |
| 394 | grn_obj *broken_column = grn_ctx_at(ctx, broken_column_id); |
| 395 | if (broken_column && grn_broken_ids_existcxx . . $ grn_broken_ids_exist(2e9db3e2e67045d8).(ctx, |
| 396 | broken_table_ids, |
| 397 | broken_column->headercxx . . $ _grn_obj#header..domain)) { |
| 398 | grn_hash_cursor_delete(ctx, cursor, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!); |
| 399 | } |
| 400 | GRN_DB_WAL_DISABLE_WAL_BEGINcxx . . $ `lib/grn_db.h:771:9`!(ctx) { grn_ctx_pop_temporary_open_space(ctx); } |
| 401 | GRN_DB_WAL_DISABLE_WAL_ENDcxx . . $ `lib/grn_db.h:776:9`!(ctx); |
| 402 | } |
| 403 | GRN_HASH_EACH_ENDcxx . . $ `include/groonga/hash.h:159:9`!(ctx, cursor); |
| 404 | } |
| 405 | |
| 406 | static void |
| 407 | grn_db_wal_recover_collect_related_broken_object_idscxx . . $ grn_db_wal_recover_collect_related_broken_object_ids(4f8716b596106d6d).( |
| 408 | grn_ctx *ctx, |
| 409 | grn_db *db, |
| 410 | grn_hash *broken_table_ids, |
| 411 | grn_hash *broken_column_ids) |
| 412 | { |
| 413 | GRN_DB_WAL_DISABLE_WAL_BEGINcxx . . $ `lib/grn_db.h:771:9`!(ctx) |
| 414 | { |
| 415 | grn_db_wal_recover_collect_depended_object_idscxx . . $ grn_db_wal_recover_collect_depended_object_ids(4f8716b596106d6d).(ctx, |
| 416 | db, |
| 417 | broken_table_ids, |
| 418 | broken_column_ids); |
| 419 | grn_db_wal_recover_remove_duplicated_broken_column_idscxx . . $ grn_db_wal_recover_remove_duplicated_broken_column_ids(4f8716b596106d6d).(ctx, |
| 420 | db, |
| 421 | broken_table_ids, |
| 422 | broken_column_ids); |
| 423 | } |
| 424 | GRN_DB_WAL_DISABLE_WAL_ENDcxx . . $ `lib/grn_db.h:776:9`!(ctx); |
| 425 | } |
| 426 | |
| 427 | static const char grn_db_wal_recovering_name_prefixcxx . . $ grn_db_wal_recovering_name_prefix.[] = "#recovering#"; |
| 428 | static const int grn_db_wal_recovering_name_prefix_lengthcxx . . $ grn_db_wal_recovering_name_prefix_length. = |
| 429 | sizeof(grn_db_wal_recovering_name_prefixcxx . . $ grn_db_wal_recovering_name_prefix.) - 1; |
| 430 | static const char grn_db_wal_broken_name_prefixcxx . . $ grn_db_wal_broken_name_prefix.[] = "#broken#"; |
| 431 | static const int grn_db_wal_broken_name_prefix_lengthcxx . . $ grn_db_wal_broken_name_prefix_length. = |
| 432 | sizeof(grn_db_wal_broken_name_prefixcxx . . $ grn_db_wal_broken_name_prefix.) - 1; |
| 433 | |
| 434 | static bool |
| 435 | grn_db_wal_recover_is_prefixed_namecxx . . $ grn_db_wal_recover_is_prefixed_name(3588f6afd5f4368e).(grn_ctx *ctx, |
| 436 | const char *name, |
| 437 | int name_length, |
| 438 | const char *prefix, |
| 439 | int prefix_length) |
| 440 | { |
| 441 | if (name_length < prefix_length) { |
| 442 | return false; |
| 443 | } |
| 444 | if (strncmp(name, prefix, prefix_length) == 0) { |
| 445 | return true; |
| 446 | } |
| 447 | const char *column_name = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!; |
| 448 | int column_name_length = 0; |
| 449 | int i; |
| 450 | for (i = 0; i < name_length; i++) { |
| 451 | if (name[i] == '.') { |
| 452 | column_name = name + i + 1; |
| 453 | column_name_length = name_length - i - 1; |
| 454 | break; |
| 455 | } |
| 456 | } |
| 457 | if (column_name_length < prefix_length) { |
| 458 | return false; |
| 459 | } |
| 460 | return strncmp(column_name, prefix, prefix_length) == 0; |
| 461 | } |
| 462 | |
| 463 | static bool |
| 464 | grn_db_wal_recover_is_recovering_object_namecxx . . $ grn_db_wal_recover_is_recovering_object_name(da3161f0ad1ba10a).(grn_ctx *ctx, |
| 465 | const char *name, |
| 466 | int name_length) |
| 467 | { |
| 468 | return grn_db_wal_recover_is_prefixed_namecxx . . $ grn_db_wal_recover_is_prefixed_name(3588f6afd5f4368e).( |
| 469 | ctx, |
| 470 | name, |
| 471 | name_length, |
| 472 | grn_db_wal_recovering_name_prefixcxx . . $ grn_db_wal_recovering_name_prefix., |
| 473 | grn_db_wal_recovering_name_prefix_lengthcxx . . $ grn_db_wal_recovering_name_prefix_length.); |
| 474 | } |
| 475 | |
| 476 | static void |
| 477 | grn_db_wal_recover_remove_recovering_objectcxx . . $ grn_db_wal_recover_remove_recovering_object(ad7e8d5d374ada68).( |
| 478 | grn_ctx *ctx, grn_db *db, grn_id id, const char *name, int name_length) |
| 479 | { |
| 480 | const char *tag = grn_db_wal_recover_tagcxx . . $ grn_db_wal_recover_tag.; |
| 481 | |
| 482 | grn_obj *object = grn_ctx_at(ctx, id); |
| 483 | if (!object) { |
| 484 | if (grn_logger_pass(ctx, GRN_LOG_DEBUG)) { |
| 485 | GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, |
| 486 | GRN_LOG_DEBUG, |
| 487 | "%s remove unopenable recovering object: <%.*s>(%u): %s", |
| 488 | tag, |
| 489 | name_length, |
| 490 | name, |
| 491 | id, |
| 492 | ctx->errbuf); |
| 493 | } |
| 494 | ERRCLRcxx . . $ `lib/grn_error.h:37:9`!(ctx); |
| 495 | grn_db_wal_recover_ensure_remove_by_idcxx . . $ grn_db_wal_recover_ensure_remove_by_id(39c852cb5629a360).(ctx, db, id); |
| 496 | return; |
| 497 | } |
| 498 | |
| 499 | if (grn_logger_pass(ctx, GRN_LOG_DEBUG)) { |
| 500 | GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, |
| 501 | GRN_LOG_DEBUG, |
| 502 | "%s remove recovering object: <%.*s>(%u)", |
| 503 | tag, |
| 504 | name_length, |
| 505 | name, |
| 506 | id); |
| 507 | } |
| 508 | grn_db_wal_recover_remove_objectcxx . . $ grn_db_wal_recover_remove_object(f492fda562814758).(ctx, db, object, id); |
| 509 | |
| 510 | const char *original_name = name - grn_db_wal_recovering_name_prefix_lengthcxx . . $ grn_db_wal_recovering_name_prefix_length.; |
| 511 | int original_name_length = |
| 512 | name_length - grn_db_wal_recovering_name_prefix_lengthcxx . . $ grn_db_wal_recovering_name_prefix_length.; |
| 513 | grn_obj broken_name; |
| 514 | GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&broken_name, 0); |
| 515 | GRN_TEXT_PUTcxx . . $ `include/groonga/groonga.h:2773:9`!(ctx, |
| 516 | &broken_name, |
| 517 | grn_db_wal_broken_name_prefix, |
| 518 | grn_db_wal_broken_name_prefix_length); |
| 519 | GRN_TEXT_PUTcxx . . $ `include/groonga/groonga.h:2773:9`!(ctx, &broken_name, original_name, original_name_length); |
| 520 | grn_obj *original_object = |
| 521 | grn_ctx_get(ctx, original_name, original_name_length); |
| 522 | grn_obj *broken_object = |
| 523 | grn_ctx_get(ctx, GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&broken_name), GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&broken_name)); |
| 524 | if (broken_object) { |
| 525 | grn_id broken_object_id = DB_OBJcxx . . $ `lib/grn_db.h:62:9`!(broken_object)->id; |
| 526 | if (original_object) { |
| 527 | if (grn_logger_pass(ctx, GRN_LOG_DEBUG)) { |
| 528 | GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, |
| 529 | GRN_LOG_DEBUG, |
| 530 | "%s remove broken object: <%.*s>(%u)", |
| 531 | tag, |
| 532 | (int)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&broken_name), |
| 533 | GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&broken_name), |
| 534 | broken_object_id); |
| 535 | } |
| 536 | grn_db_wal_recover_remove_objectcxx . . $ grn_db_wal_recover_remove_object(f492fda562814758).(ctx, |
| 537 | db, |
| 538 | broken_object, |
| 539 | broken_object_id); |
| 540 | } else { |
| 541 | if (grn_logger_pass(ctx, GRN_LOG_DEBUG)) { |
| 542 | GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, |
| 543 | GRN_LOG_DEBUG, |
| 544 | "%s reuse broken object: <%.*s>(%u)", |
| 545 | tag, |
| 546 | (int)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&broken_name), |
| 547 | GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&broken_name), |
| 548 | broken_object_id); |
| 549 | } |
| 550 | grn_obj_rename(ctx, broken_object, original_name, original_name_length); |
| 551 | } |
| 552 | } |
| 553 | GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &broken_name); |
| 554 | } |
| 555 | |
| 556 | static void |
| 557 | grn_db_wal_recover_remove_recovering_objectscxx . . $ grn_db_wal_recover_remove_recovering_objects(ea3523c40d20cded).(grn_ctx *ctx, grn_db *db) |
| 558 | { |
| 559 | GRN_TABLE_EACH_BEGINcxx . . $ `include/groonga/table.h:614:9`!(ctx, db->keys, cursor, id) |
| 560 | { |
| 561 | void *key; |
| 562 | int key_size = grn_table_cursor_get_key(ctx, cursor, &key); |
| 563 | auto name = static_cast<char *>(key); |
| 564 | if (!grn_db_wal_recover_is_recovering_object_namecxx . . $ grn_db_wal_recover_is_recovering_object_name(da3161f0ad1ba10a).(ctx, name, key_size)) { |
| 565 | continue; |
| 566 | } |
| 567 | grn_ctx_push_temporary_open_space(ctx); |
| 568 | grn_db_wal_recover_remove_recovering_objectcxx . . $ grn_db_wal_recover_remove_recovering_object(ad7e8d5d374ada68).(ctx, db, id, name, key_size); |
| 569 | GRN_DB_WAL_DISABLE_WAL_BEGINcxx . . $ `lib/grn_db.h:771:9`!(ctx) { grn_ctx_pop_temporary_open_space(ctx); } |
| 570 | GRN_DB_WAL_DISABLE_WAL_ENDcxx . . $ `lib/grn_db.h:776:9`!(ctx); |
| 571 | } |
| 572 | GRN_TABLE_EACH_ENDcxx . . $ `include/groonga/table.h:665:9`!(ctx, cursor); |
| 573 | } |
| 574 | |
| 575 | static bool |
| 576 | grn_db_wal_recover_is_broken_object_namecxx . . $ grn_db_wal_recover_is_broken_object_name(da3161f0ad1ba10a).(grn_ctx *ctx, |
| 577 | const char *name, |
| 578 | int name_length) |
| 579 | { |
| 580 | return grn_db_wal_recover_is_prefixed_namecxx . . $ grn_db_wal_recover_is_prefixed_name(3588f6afd5f4368e).( |
| 581 | ctx, |
| 582 | name, |
| 583 | name_length, |
| 584 | grn_db_wal_broken_name_prefixcxx . . $ grn_db_wal_broken_name_prefix., |
| 585 | grn_db_wal_broken_name_prefix_lengthcxx . . $ grn_db_wal_broken_name_prefix_length.); |
| 586 | } |
| 587 | |
| 588 | static void |
| 589 | grn_db_wal_recover_remove_broken_objectcxx . . $ grn_db_wal_recover_remove_broken_object(ad7e8d5d374ada68).( |
| 590 | grn_ctx *ctx, grn_db *db, grn_id id, const char *name, int name_length) |
| 591 | { |
| 592 | const char *tag = grn_db_wal_recover_tagcxx . . $ grn_db_wal_recover_tag.; |
| 593 | |
| 594 | grn_obj *object = grn_ctx_at(ctx, id); |
| 595 | if (!object) { |
| 596 | if (grn_logger_pass(ctx, GRN_LOG_DEBUG)) { |
| 597 | GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, |
| 598 | GRN_LOG_DEBUG, |
| 599 | "%s remove unopenable broken object: <%.*s>(%u): %s", |
| 600 | tag, |
| 601 | name_length, |
| 602 | name, |
| 603 | id, |
| 604 | ctx->errbuf); |
| 605 | } |
| 606 | ERRCLRcxx . . $ `lib/grn_error.h:37:9`!(ctx); |
| 607 | grn_db_wal_recover_ensure_remove_by_idcxx . . $ grn_db_wal_recover_ensure_remove_by_id(39c852cb5629a360).(ctx, db, id); |
| 608 | return; |
| 609 | } |
| 610 | |
| 611 | if (grn_logger_pass(ctx, GRN_LOG_DEBUG)) { |
| 612 | GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, |
| 613 | GRN_LOG_DEBUG, |
| 614 | "%s remove broken object: <%.*s>(%u)", |
| 615 | tag, |
| 616 | name_length, |
| 617 | name, |
| 618 | id); |
| 619 | } |
| 620 | grn_db_wal_recover_remove_objectcxx . . $ grn_db_wal_recover_remove_object(f492fda562814758).(ctx, db, object, id); |
| 621 | } |
| 622 | |
| 623 | static void |
| 624 | grn_db_wal_recover_remove_broken_objectscxx . . $ grn_db_wal_recover_remove_broken_objects(ea3523c40d20cded).(grn_ctx *ctx, grn_db *db) |
| 625 | { |
| 626 | GRN_TABLE_EACH_BEGINcxx . . $ `include/groonga/table.h:614:9`!(ctx, db->keys, cursor, id) |
| 627 | { |
| 628 | void *key; |
| 629 | int key_size = grn_table_cursor_get_key(ctx, cursor, &key); |
| 630 | auto name = static_cast<char *>(key); |
| 631 | if (!grn_db_wal_recover_is_broken_object_namecxx . . $ grn_db_wal_recover_is_broken_object_name(da3161f0ad1ba10a).(ctx, name, key_size)) { |
| 632 | continue; |
| 633 | } |
| 634 | grn_ctx_push_temporary_open_space(ctx); |
| 635 | grn_db_wal_recover_remove_broken_objectcxx . . $ grn_db_wal_recover_remove_broken_object(ad7e8d5d374ada68).(ctx, db, id, name, key_size); |
| 636 | GRN_DB_WAL_DISABLE_WAL_BEGINcxx . . $ `lib/grn_db.h:771:9`!(ctx) { grn_ctx_pop_temporary_open_space(ctx); } |
| 637 | GRN_DB_WAL_DISABLE_WAL_ENDcxx . . $ `lib/grn_db.h:776:9`!(ctx); |
| 638 | } |
| 639 | GRN_TABLE_EACH_ENDcxx . . $ `include/groonga/table.h:665:9`!(ctx, cursor); |
| 640 | } |
| 641 | |
| 642 | static void |
| 643 | grn_db_wal_recover_copy_tablecxx . . $ grn_db_wal_recover_copy_table(91292fe935144900).(grn_ctx *ctx, grn_obj *table, grn_id_map *id_map) |
| 644 | { |
| 645 | GRN_DEFINE_NAMEcxx . . $ `lib/grn_db.h:90:9`!(table); |
| 646 | GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, |
| 647 | GRN_LOG_NOTICE, |
| 648 | "%s rebuild broken table: <%.*s>(%u)", |
| 649 | grn_db_wal_recover_tag, |
| 650 | name_size, |
| 651 | name, |
| 652 | DB_OBJcxx . . $ `lib/grn_db.h:62:9`!(table)->id); |
| 653 | grn_obj new_name; |
| 654 | GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&new_name, 0); |
| 655 | GRN_TEXT_PUTcxx . . $ `include/groonga/groonga.h:2773:9`!(ctx, |
| 656 | &new_name, |
| 657 | grn_db_wal_recovering_name_prefix, |
| 658 | grn_db_wal_recovering_name_prefix_length); |
| 659 | GRN_TEXT_PUTcxx . . $ `include/groonga/groonga.h:2773:9`!(ctx, &new_name, name, name_size); |
| 660 | grn_obj *new_table = |
| 661 | grn_table_create_similar_id_map(ctx, |
| 662 | GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&new_name), |
| 663 | GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&new_name), |
| 664 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!, |
| 665 | table, |
| 666 | id_map); |
| 667 | GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &new_name); |
| 668 | if (new_table) { |
| 669 | grn_id_map_add(ctx, id_map, DB_OBJcxx . . $ `lib/grn_db.h:62:9`!(table)->id, DB_OBJcxx . . $ `lib/grn_db.h:62:9`!(new_table)->id); |
| 670 | GRN_DB_WAL_DISABLE_WAL_BEGINcxx . . $ `lib/grn_db.h:771:9`!(ctx) { grn_table_copy(ctx, table, new_table); } |
| 671 | GRN_DB_WAL_DISABLE_WAL_ENDcxx . . $ `lib/grn_db.h:776:9`!(ctx); |
| 672 | grn_obj_unref(ctx, new_table); |
| 673 | } |
| 674 | } |
| 675 | |
| 676 | static bool |
| 677 | grn_db_wal_recover_is_data_columncxx . . $ grn_db_wal_recover_is_data_column(a5760e5c319a06ee).(grn_ctx *ctx, grn_obj *column) |
| 678 | { |
| 679 | if (grn_obj_have_source(ctx, column)) { |
| 680 | return false; |
| 681 | } |
| 682 | if (grn_obj_is_index_column(ctx, column)) { |
| 683 | return false; |
| 684 | } |
| 685 | return true; |
| 686 | } |
| 687 | |
| 688 | static void |
| 689 | grn_db_wal_recover_copy_data_columncxx . . $ grn_db_wal_recover_copy_data_column(ce7f4081a5ab8e24).(grn_ctx *ctx, |
| 690 | grn_obj *column, |
| 691 | grn_obj *new_table, |
| 692 | grn_id_map *id_map) |
| 693 | { |
| 694 | if (!grn_db_wal_recover_is_data_columncxx . . $ grn_db_wal_recover_is_data_column(a5760e5c319a06ee).(ctx, column)) { |
| 695 | return; |
| 696 | } |
| 697 | if (grn_logger_pass(ctx, GRN_LOG_NOTICE)) { |
| 698 | GRN_DEFINE_NAMEcxx . . $ `lib/grn_db.h:90:9`!(column); |
| 699 | GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, |
| 700 | GRN_LOG_NOTICE, |
| 701 | "%s rebuild broken data column: <%.*s>(%u)", |
| 702 | grn_db_wal_recover_tag, |
| 703 | name_size, |
| 704 | name, |
| 705 | DB_OBJcxx . . $ `lib/grn_db.h:62:9`!(column)->id); |
| 706 | } |
| 707 | char name[GRN_TABLE_MAX_KEY_SIZEcxx . . $ `include/groonga/table.h:26:9`!]; |
| 708 | int name_size = grn_column_name(ctx, column, name, sizeof(name)); |
| 709 | grn_obj new_name; |
| 710 | bool need_new_table_unref = false; |
| 711 | if (new_table) { |
| 712 | GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&new_name, GRN_OBJ_DO_SHALLOW_COPYcxx . . $ `include/groonga/groonga.h:2732:9`!); |
| 713 | GRN_TEXT_SETcxx . . $ `include/groonga/groonga.h:2761:9`!(ctx, &new_name, name, name_size); |
| 714 | } else { |
| 715 | GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&new_name, 0); |
| 716 | GRN_TEXT_PUTcxx . . $ `include/groonga/groonga.h:2773:9`!(ctx, |
| 717 | &new_name, |
| 718 | grn_db_wal_recovering_name_prefix, |
| 719 | grn_db_wal_recovering_name_prefix_length); |
| 720 | GRN_TEXT_PUTcxx . . $ `include/groonga/groonga.h:2773:9`!(ctx, &new_name, name, name_size); |
| 721 | new_table = grn_ctx_at(ctx, column->headercxx . . $ _grn_obj#header..domain); |
| 722 | need_new_table_unref = true; |
| 723 | } |
| 724 | grn_obj *new_column = |
| 725 | grn_column_create_similar_id_map(ctx, |
| 726 | new_table, |
| 727 | GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&new_name), |
| 728 | GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&new_name), |
| 729 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!, |
| 730 | column, |
| 731 | id_map); |
| 732 | GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &new_name); |
| 733 | if (new_column) { |
| 734 | grn_id_map_add(ctx, id_map, DB_OBJcxx . . $ `lib/grn_db.h:62:9`!(column)->id, DB_OBJcxx . . $ `lib/grn_db.h:62:9`!(new_column)->id); |
| 735 | GRN_DB_WAL_DISABLE_WAL_BEGINcxx . . $ `lib/grn_db.h:771:9`!(ctx) |
| 736 | { |
| 737 | grn_column_copy(ctx, column, new_column); |
| 738 | } |
| 739 | GRN_DB_WAL_DISABLE_WAL_ENDcxx . . $ `lib/grn_db.h:776:9`!(ctx); |
| 740 | grn_obj_unref(ctx, new_column); |
| 741 | } |
| 742 | if (need_new_table_unref) { |
| 743 | grn_obj_unref(ctx, new_table); |
| 744 | } |
| 745 | } |
| 746 | |
| 747 | static void |
| 748 | grn_db_wal_recover_copy_non_reference_data_columncxx . . $ grn_db_wal_recover_copy_non_reference_data_column(ce7f4081a5ab8e24).(grn_ctx *ctx, |
| 749 | grn_obj *column, |
| 750 | grn_obj *new_table, |
| 751 | grn_id_map *id_map) |
| 752 | { |
| 753 | if (!grn_id_is_builtin(ctx, DB_OBJcxx . . $ `lib/grn_db.h:62:9`!(column)->range)) { |
| 754 | return; |
| 755 | } |
| 756 | grn_db_wal_recover_copy_data_columncxx . . $ grn_db_wal_recover_copy_data_column(ce7f4081a5ab8e24).(ctx, column, new_table, id_map); |
| 757 | } |
| 758 | |
| 759 | static void |
| 760 | grn_db_wal_recover_copy_non_reference_data_columnscxx . . $ grn_db_wal_recover_copy_non_reference_data_columns(91292fe935144900).(grn_ctx *ctx, |
| 761 | grn_obj *table, |
| 762 | grn_id_map *id_map) |
| 763 | { |
| 764 | grn_hash *columns = grn_table_all_columns(ctx, table); |
| 765 | if (grn_hash_size(ctx, columns) == 0) { |
| 766 | return; |
| 767 | } |
| 768 | |
| 769 | GRN_DEFINE_NAMEcxx . . $ `lib/grn_db.h:90:9`!(table); |
| 770 | grn_obj new_name; |
| 771 | GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&new_name, 0); |
| 772 | GRN_TEXT_PUTcxx . . $ `include/groonga/groonga.h:2773:9`!(ctx, |
| 773 | &new_name, |
| 774 | grn_db_wal_recovering_name_prefix, |
| 775 | grn_db_wal_recovering_name_prefix_length); |
| 776 | GRN_TEXT_PUTcxx . . $ `include/groonga/groonga.h:2773:9`!(ctx, &new_name, name, name_size); |
| 777 | grn_obj *new_table = |
| 778 | grn_ctx_get(ctx, GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&new_name), GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&new_name)); |
| 779 | GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &new_name); |
| 780 | |
| 781 | GRN_HASH_EACH_BEGINcxx . . $ `include/groonga/hash.h:141:9`!(ctx, columns, cursor, column_entry_id) |
| 782 | { |
| 783 | void *key; |
| 784 | grn_hash_cursor_get_key(ctx, cursor, &key); |
| 785 | grn_id column_id = *((grn_id *)key); |
| 786 | grn_obj *column = grn_ctx_at(ctx, column_id); |
| 787 | if (!column) { |
| 788 | continue; |
| 789 | } |
| 790 | grn_db_wal_recover_copy_non_reference_data_columncxx . . $ grn_db_wal_recover_copy_non_reference_data_column(ce7f4081a5ab8e24).(ctx, |
| 791 | column, |
| 792 | new_table, |
| 793 | id_map); |
| 794 | grn_obj_unref(ctx, column); |
| 795 | if (ctx->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESS) { |
| 796 | break; |
| 797 | } |
| 798 | } |
| 799 | GRN_HASH_EACH_ENDcxx . . $ `include/groonga/hash.h:159:9`!(ctx, cursor); |
| 800 | |
| 801 | grn_obj_unref(ctx, new_table); |
| 802 | } |
| 803 | |
| 804 | static void |
| 805 | grn_db_wal_recover_copy_reference_data_columncxx . . $ grn_db_wal_recover_copy_reference_data_column(ce7f4081a5ab8e24).(grn_ctx *ctx, |
| 806 | grn_obj *column, |
| 807 | grn_obj *new_table, |
| 808 | grn_id_map *id_map) |
| 809 | { |
| 810 | if (grn_id_is_builtin(ctx, DB_OBJcxx . . $ `lib/grn_db.h:62:9`!(column)->range)) { |
| 811 | return; |
| 812 | } |
| 813 | grn_db_wal_recover_copy_data_columncxx . . $ grn_db_wal_recover_copy_data_column(ce7f4081a5ab8e24).(ctx, column, new_table, id_map); |
| 814 | } |
| 815 | |
| 816 | static void |
| 817 | grn_db_wal_recover_copy_reference_data_columnscxx . . $ grn_db_wal_recover_copy_reference_data_columns(91292fe935144900).(grn_ctx *ctx, |
| 818 | grn_obj *table, |
| 819 | grn_id_map *id_map) |
| 820 | { |
| 821 | grn_hash *columns = grn_table_all_columns(ctx, table); |
| 822 | if (grn_hash_size(ctx, columns) == 0) { |
| 823 | return; |
| 824 | } |
| 825 | |
| 826 | GRN_DEFINE_NAMEcxx . . $ `lib/grn_db.h:90:9`!(table); |
| 827 | grn_obj new_name; |
| 828 | GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&new_name, 0); |
| 829 | GRN_TEXT_PUTcxx . . $ `include/groonga/groonga.h:2773:9`!(ctx, |
| 830 | &new_name, |
| 831 | grn_db_wal_recovering_name_prefix, |
| 832 | grn_db_wal_recovering_name_prefix_length); |
| 833 | GRN_TEXT_PUTcxx . . $ `include/groonga/groonga.h:2773:9`!(ctx, &new_name, name, name_size); |
| 834 | grn_obj *new_table = |
| 835 | grn_ctx_get(ctx, GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&new_name), GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&new_name)); |
| 836 | GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &new_name); |
| 837 | |
| 838 | GRN_HASH_EACH_BEGINcxx . . $ `include/groonga/hash.h:141:9`!(ctx, columns, cursor, column_entry_id) |
| 839 | { |
| 840 | void *key; |
| 841 | grn_hash_cursor_get_key(ctx, cursor, &key); |
| 842 | grn_id column_id = *((grn_id *)key); |
| 843 | grn_obj *column = grn_ctx_at(ctx, column_id); |
| 844 | if (!column) { |
| 845 | continue; |
| 846 | } |
| 847 | grn_db_wal_recover_copy_reference_data_columncxx . . $ grn_db_wal_recover_copy_reference_data_column(ce7f4081a5ab8e24).(ctx, |
| 848 | column, |
| 849 | new_table, |
| 850 | id_map); |
| 851 | grn_obj_unref(ctx, column); |
| 852 | if (ctx->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESS) { |
| 853 | break; |
| 854 | } |
| 855 | } |
| 856 | GRN_HASH_EACH_ENDcxx . . $ `include/groonga/hash.h:159:9`!(ctx, cursor); |
| 857 | |
| 858 | grn_obj_unref(ctx, new_table); |
| 859 | } |
| 860 | |
| 861 | static void |
| 862 | grn_db_wal_recover_rename_columncxx . . $ grn_db_wal_recover_rename_column(41f7f642728b895b).(grn_ctx *ctx, |
| 863 | grn_db *db, |
| 864 | grn_id broken_column_id, |
| 865 | grn_id_map *id_map) |
| 866 | { |
| 867 | grn_id recovering_column_id = |
| 868 | grn_id_map_resolve(ctx, id_map, broken_column_id); |
| 869 | grn_obj *recovering_column = grn_ctx_at(ctx, recovering_column_id); |
| 870 | char recovering_column_name[GRN_TABLE_MAX_KEY_SIZEcxx . . $ `include/groonga/table.h:26:9`!]; |
| 871 | int recovering_column_name_length = |
| 872 | grn_column_name(ctx, |
| 873 | recovering_column, |
| 874 | recovering_column_name, |
| 875 | sizeof(recovering_column_name)); |
| 876 | char *column_name = |
| 877 | recovering_column_name + grn_db_wal_recovering_name_prefix_lengthcxx . . $ grn_db_wal_recovering_name_prefix_length.; |
| 878 | int column_name_length = |
| 879 | recovering_column_name_length - grn_db_wal_recovering_name_prefix_lengthcxx . . $ grn_db_wal_recovering_name_prefix_length.; |
| 880 | |
| 881 | grn_obj *broken_column = grn_ctx_at(ctx, broken_column_id); |
| 882 | if (broken_column) { |
| 883 | grn_obj broken_column_name; |
| 884 | GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&broken_column_name, 0); |
| 885 | GRN_TEXT_PUTcxx . . $ `include/groonga/groonga.h:2773:9`!(ctx, |
| 886 | &broken_column_name, |
| 887 | grn_db_wal_broken_name_prefix, |
| 888 | grn_db_wal_broken_name_prefix_length); |
| 889 | GRN_TEXT_PUTcxx . . $ `include/groonga/groonga.h:2773:9`!(ctx, &broken_column_name, column_name, column_name_length); |
| 890 | grn_column_rename(ctx, |
| 891 | broken_column, |
| 892 | GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&broken_column_name), |
| 893 | GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&broken_column_name)); |
| 894 | GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &broken_column_name); |
| 895 | } |
| 896 | |
| 897 | grn_column_rename(ctx, recovering_column, column_name, column_name_length); |
| 898 | if (ctx->rccxx . . $ _grn_ctx#rc. == GRN_SUCCESS) { |
| 899 | if (broken_column) { |
| 900 | grn_db_wal_recover_remove_objectcxx . . $ grn_db_wal_recover_remove_object(f492fda562814758).(ctx, db, broken_column, GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!); |
| 901 | } |
| 902 | } |
| 903 | if (grn_logger_pass(ctx, GRN_LOG_NOTICE)) { |
| 904 | GRN_DEFINE_NAMEcxx . . $ `lib/grn_db.h:90:9`!(recovering_column); |
| 905 | GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, |
| 906 | GRN_LOG_NOTICE, |
| 907 | "%s succeeded to rebuild broken column: <%.*s>(%u)", |
| 908 | grn_db_wal_recover_tag, |
| 909 | name_size, |
| 910 | name, |
| 911 | DB_OBJcxx . . $ `lib/grn_db.h:62:9`!(recovering_column)->id); |
| 912 | } |
| 913 | grn_obj_unref(ctx, recovering_column); |
| 914 | } |
| 915 | |
| 916 | static void |
| 917 | grn_db_wal_recover_rename_tablecxx . . $ grn_db_wal_recover_rename_table(41f7f642728b895b).(grn_ctx *ctx, |
| 918 | grn_db *db, |
| 919 | grn_id broken_table_id, |
| 920 | grn_id_map *id_map) |
| 921 | { |
| 922 | grn_id new_table_id = grn_id_map_resolve(ctx, id_map, broken_table_id); |
| 923 | grn_obj *new_table = grn_ctx_at(ctx, new_table_id); |
| 924 | GRN_DEFINE_NAME_CUSTOMcxx . . $ `lib/grn_db.h:64:9`!(new_table, new_table_name); |
| 925 | const char *table_name = |
| 926 | new_table_name + grn_db_wal_recovering_name_prefix_lengthcxx . . $ grn_db_wal_recovering_name_prefix_length.; |
| 927 | int table_name_length = |
| 928 | new_table_name_size - grn_db_wal_recovering_name_prefix_lengthcxx . . $ grn_db_wal_recovering_name_prefix_length.; |
| 929 | |
| 930 | grn_obj *broken_table = grn_ctx_at(ctx, broken_table_id); |
| 931 | if (broken_table) { |
| 932 | grn_obj broken_table_name; |
| 933 | GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&broken_table_name, 0); |
| 934 | GRN_TEXT_PUTcxx . . $ `include/groonga/groonga.h:2773:9`!(ctx, |
| 935 | &broken_table_name, |
| 936 | grn_db_wal_broken_name_prefix, |
| 937 | grn_db_wal_broken_name_prefix_length); |
| 938 | GRN_TEXT_PUTcxx . . $ `include/groonga/groonga.h:2773:9`!(ctx, &broken_table_name, table_name, table_name_length); |
| 939 | grn_table_rename(ctx, |
| 940 | broken_table, |
| 941 | GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&broken_table_name), |
| 942 | GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&broken_table_name)); |
| 943 | GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &broken_table_name); |
| 944 | } |
| 945 | |
| 946 | grn_table_rename(ctx, new_table, table_name, table_name_length); |
| 947 | if (ctx->rccxx . . $ _grn_ctx#rc. == GRN_SUCCESS) { |
| 948 | if (broken_table) { |
| 949 | grn_db_wal_recover_remove_objectcxx . . $ grn_db_wal_recover_remove_object(f492fda562814758).(ctx, db, broken_table, GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!); |
| 950 | } |
| 951 | } |
| 952 | GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, |
| 953 | GRN_LOG_NOTICE, |
| 954 | "%s succeeded to rebuild broken table: <%.*s>(%u)", |
| 955 | grn_db_wal_recover_tag, |
| 956 | table_name_length, |
| 957 | table_name, |
| 958 | DB_OBJcxx . . $ `lib/grn_db.h:62:9`!(new_table)->id); |
| 959 | grn_obj_unref(ctx, new_table); |
| 960 | } |
| 961 | |
| 962 | namespacecxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/ { |
| 963 | class DBWALCopyRecoverercxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer# { |
| 964 | private: |
| 965 | grn_ctx *ctx_cxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#ctx_.; |
| 966 | grn_hash *broken_table_ids_cxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#broken_table_ids_.; |
| 967 | grn_hash *broken_column_ids_cxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#broken_column_ids_.; |
| 968 | grn_id_map *id_map_cxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#id_map_.; |
| 969 | grncxx . . $ grn/::TaskExecutorcxx . . $ grn/TaskExecutor# *task_executor_cxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#task_executor_.; |
| 970 | |
| 971 | public: |
| 972 | explicit DBWALCopyRecoverercxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#DBWALCopyRecoverer(7303a3526d3893cb).(grn_ctx *ctx, |
| 973 | grn_hash *broken_table_ids, |
| 974 | grn_hash *broken_column_ids, |
| 975 | grn_id_map *id_map) |
| 976 | : ctx_cxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#ctx_.(ctx), |
| 977 | broken_table_ids_cxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#broken_table_ids_.(broken_table_ids), |
| 978 | broken_column_ids_cxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#broken_column_ids_.(broken_column_ids), |
| 979 | id_map_cxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#id_map_.(id_map), |
| 980 | task_executor_cxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#task_executor_.(grn_ctx_get_task_executorcxx . . $ grn_ctx_get_task_executor(a6ad17b0d499b7c8).(ctx)) |
| 981 | { |
| 982 | } |
| 983 | |
| 984 | void |
| 985 | rebuild_auto_generated_columnscxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#rebuild_auto_generated_columns(49f6e7a06ebc5aa8).() |
| 986 | { |
| 987 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<grn_id, grn_id>> targetscxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 988 | GRN_HASH_EACH_BEGINcxx . . $ `include/groonga/hash.h:141:9`!(ctx_, broken_table_ids_, cursor, entry_id) |
| 989 | { |
| 990 | grn_ctx_push_temporary_open_space(ctx_cxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#ctx_.); |
| 991 | grn_id broken_table_id = grn_broken_ids_cursor_getcxx . . $ grn_broken_ids_cursor_get(6f2ad840d1580522).(ctx_cxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#ctx_., cursor); |
| 992 | grn_obj *broken_table = grn_ctx_at(ctx_cxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#ctx_., broken_table_id); |
| 993 | if (broken_table) { |
| 994 | collect_broken_auto_generated_columnscxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#collect_broken_auto_generated_columns(2c704378af233e37).(broken_table, targets); |
| 995 | grn_obj_unref(ctx_cxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#ctx_., broken_table); |
| 996 | } |
| 997 | GRN_DB_WAL_DISABLE_WAL_BEGINcxx . . $ `lib/grn_db.h:771:9`!(ctx_) |
| 998 | { |
| 999 | grn_ctx_pop_temporary_open_space(ctx_cxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#ctx_.); |
| 1000 | } |
| 1001 | GRN_DB_WAL_DISABLE_WAL_ENDcxx . . $ `lib/grn_db.h:776:9`!(ctx_); |
| 1002 | if (ctx_cxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#ctx_.->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESS) { |
| 1003 | return; |
| 1004 | } |
| 1005 | } |
| 1006 | GRN_HASH_EACH_ENDcxx . . $ `include/groonga/hash.h:159:9`!(ctx_, cursor); |
| 1007 | |
| 1008 | GRN_HASH_EACH_BEGINcxx . . $ `include/groonga/hash.h:141:9`!(ctx_, broken_column_ids_, cursor, entry_id) |
| 1009 | { |
| 1010 | grn_ctx_push_temporary_open_space(ctx_cxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#ctx_.); |
| 1011 | grn_id broken_column_id = grn_broken_ids_cursor_getcxx . . $ grn_broken_ids_cursor_get(6f2ad840d1580522).(ctx_cxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#ctx_., cursor); |
| 1012 | grn_obj *broken_column = grn_ctx_at(ctx_cxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#ctx_., broken_column_id); |
| 1013 | if (broken_column) { |
| 1014 | if (is_auto_generated_columncxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#is_auto_generated_column(a5760e5c319a06ee).(ctx_cxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#ctx_., broken_column)) { |
| 1015 | targets.emplace_backcxx . . $ std/vector#emplace_back(a1bcdfdabc3a37df).(GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!, broken_column_id); |
| 1016 | } |
| 1017 | grn_obj_unref(ctx_cxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#ctx_., broken_column); |
| 1018 | } |
| 1019 | GRN_DB_WAL_DISABLE_WAL_BEGINcxx . . $ `lib/grn_db.h:771:9`!(ctx_) |
| 1020 | { |
| 1021 | grn_ctx_pop_temporary_open_space(ctx_cxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#ctx_.); |
| 1022 | } |
| 1023 | GRN_DB_WAL_DISABLE_WAL_ENDcxx . . $ `lib/grn_db.h:776:9`!(ctx_); |
| 1024 | if (ctx_cxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#ctx_.->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESS) { |
| 1025 | return; |
| 1026 | } |
| 1027 | } |
| 1028 | GRN_HASH_EACH_ENDcxx . . $ `include/groonga/hash.h:159:9`!(ctx_, cursor); |
| 1029 | |
| 1030 | auto n_columns = targets.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); |
| 1031 | if (n_columns == 0) { |
| 1032 | return; |
| 1033 | } |
| 1034 | |
| 1035 | auto n_workers = task_executor_cxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#task_executor_.->get_n_workerscxx . . $ grn/TaskExecutor#get_n_workers(db52760e79bf9054).(); |
| 1036 | if (n_workers == 0) { |
| 1037 | n_workers = 1; |
| 1038 | } |
| 1039 | n_workers = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(n_workers, static_cast<uint32_tcxx . . $ uint32_t#>(n_columns)); |
| 1040 | auto n_columns_per_worker = (n_columns / n_workers) + 1; |
| 1041 | // We can't use temporary open space with parallel mode because |
| 1042 | // it may close objects that are still used by other thread. But |
| 1043 | // we can use temporary open space with reference count |
| 1044 | // mode. Because it doesn't close used objects. |
| 1045 | const bool use_temporary_open_space = |
| 1046 | (!task_executor_cxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#task_executor_.->is_parallelcxx . . $ grn/TaskExecutor#is_parallel(c9857a73d68e59ba).() || grn_is_reference_count_enable()); |
| 1047 | for (size_t i = 0; i < n_workers; i++) { |
| 1048 | auto execute = [&, i]() { |
| 1049 | size_t start = n_columns_per_worker * i; |
| 1050 | size_t end = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(n_columns_per_worker * (i + 1), n_columns); |
| 1051 | grn_ctx *task_ctx = ctx_cxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#ctx_.; |
| 1052 | grn_ctx *child_ctx = nullptr; |
| 1053 | if (task_executor_cxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#task_executor_.->is_parallelcxx . . $ grn/TaskExecutor#is_parallel(c9857a73d68e59ba).()) { |
| 1054 | task_ctx = child_ctx = grn_ctx_pull_child(ctx_cxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#ctx_.); |
| 1055 | } |
| 1056 | grncxx . . $ grn/::ChildCtxReleasercxx . . $ grn/ChildCtxReleaser# releasercxx . . $ grn/ChildCtxReleaser#ChildCtxReleaser(7e746d4b1777d1a6).(ctx_cxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#ctx_., child_ctx); |
| 1057 | for (size_t j = start; j < end; ++j) { |
| 1058 | if (use_temporary_open_space) { |
| 1059 | grn_ctx_push_temporary_open_space(task_ctx); |
| 1060 | } |
| 1061 | auto [new_table_id, broken_column_id] = targetscxx . . $ std/pair#pair(31533a781ed7dba3).[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).j]; |
| 1062 | grn_obj *new_table = nullptr; |
| 1063 | if (new_table_id != GRN_ID_NILcxx . . $ `include/groonga/groonga.h:55:9`!) { |
| 1064 | new_table = grn_ctx_at(task_ctx, new_table_id); |
| 1065 | } |
| 1066 | auto broken_column = grn_ctx_at(task_ctx, broken_column_id); |
| 1067 | if (broken_column) { |
| 1068 | rebuild_auto_generated_columncxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#rebuild_auto_generated_column(99eba0d3a8372d65).(task_ctx, broken_column, new_table); |
| 1069 | grn_obj_unref(task_ctx, broken_column); |
| 1070 | } |
| 1071 | if (new_table) { |
| 1072 | grn_obj_unref(task_ctx, new_table); |
| 1073 | } |
| 1074 | if (use_temporary_open_space) { |
| 1075 | GRN_DB_WAL_DISABLE_WAL_BEGINcxx . . $ `lib/grn_db.h:771:9`!(task_ctx) |
| 1076 | { |
| 1077 | grn_ctx_pop_temporary_open_space(task_ctx); |
| 1078 | } |
| 1079 | GRN_DB_WAL_DISABLE_WAL_ENDcxx . . $ `lib/grn_db.h:776:9`!(task_ctx); |
| 1080 | } |
| 1081 | if (task_ctx->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESS) { |
| 1082 | break; |
| 1083 | } |
| 1084 | } |
| 1085 | return task_ctx->rccxx . . $ _grn_ctx#rc. == GRN_SUCCESS; |
| 1086 | }; |
| 1087 | task_executor_cxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#task_executor_.->executecxx . . $ grn/TaskExecutor#execute(61277e778d1aa7c1).(i, execute, grn_db_wal_recover_tagcxx . . $ grn_db_wal_recover_tag.); |
| 1088 | } |
| 1089 | task_executor_cxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#task_executor_.->wait_allcxx . . $ grn/TaskExecutor#wait_all(c9857a73d68e59ba).(); |
| 1090 | } |
| 1091 | |
| 1092 | private: |
| 1093 | bool |
| 1094 | is_auto_generated_columncxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#is_auto_generated_column(a5760e5c319a06ee).(grn_ctx *ctx, grn_obj *column) |
| 1095 | { |
| 1096 | return !grn_db_wal_recover_is_data_columncxx . . $ grn_db_wal_recover_is_data_column(a5760e5c319a06ee).(ctx, column); |
| 1097 | } |
| 1098 | |
| 1099 | void |
| 1100 | collect_broken_auto_generated_columnscxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#collect_broken_auto_generated_columns(2c704378af233e37).( |
| 1101 | grn_obj *table, stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<grn_id, grn_id>> &targets) |
| 1102 | { |
| 1103 | auto columns = grn_table_all_columns(ctx_cxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#ctx_., table); |
| 1104 | if (grn_hash_size(ctx_cxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#ctx_., columns) == 0) { |
| 1105 | return; |
| 1106 | } |
| 1107 | |
| 1108 | auto ctx = ctx_cxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#ctx_.; |
| 1109 | GRN_DEFINE_NAMEcxx . . $ `lib/grn_db.h:90:9`!(table); |
| 1110 | grn_obj new_name; |
| 1111 | GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&new_name, 0); |
| 1112 | GRN_TEXT_PUTcxx . . $ `include/groonga/groonga.h:2773:9`!(ctx_, |
| 1113 | &new_name, |
| 1114 | grn_db_wal_recovering_name_prefix, |
| 1115 | grn_db_wal_recovering_name_prefix_length); |
| 1116 | GRN_TEXT_PUTcxx . . $ `include/groonga/groonga.h:2773:9`!(ctx, &new_name, name, name_size); |
| 1117 | grn_obj *new_table = |
| 1118 | grn_ctx_get(ctx_cxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#ctx_., GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&new_name), GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&new_name)); |
| 1119 | GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &new_name); |
| 1120 | |
| 1121 | auto new_table_id = DB_OBJcxx . . $ `lib/grn_db.h:62:9`!(new_table)->id; |
| 1122 | GRN_HASH_EACH_BEGINcxx . . $ `include/groonga/hash.h:141:9`!(ctx, columns, cursor, column_entry_id) |
| 1123 | { |
| 1124 | void *key; |
| 1125 | grn_hash_cursor_get_key(ctx, cursor, &key); |
| 1126 | grn_id column_id = *((grn_id *)key); |
| 1127 | grn_obj *column = grn_ctx_at(ctx, column_id); |
| 1128 | if (!column) { |
| 1129 | continue; |
| 1130 | } |
| 1131 | if (is_auto_generated_columncxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#is_auto_generated_column(a5760e5c319a06ee).(ctx, column)) { |
| 1132 | targets.emplace_backcxx . . $ std/vector#emplace_back(a1bcdfdabc3a37df).(new_table_id, column_id); |
| 1133 | } |
| 1134 | grn_obj_unref(ctx, column); |
| 1135 | if (ctx->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESS) { |
| 1136 | break; |
| 1137 | } |
| 1138 | } |
| 1139 | GRN_HASH_EACH_ENDcxx . . $ `include/groonga/hash.h:159:9`!(ctx, cursor); |
| 1140 | |
| 1141 | grn_obj_unref(ctx, new_table); |
| 1142 | } |
| 1143 | |
| 1144 | void |
| 1145 | rebuild_auto_generated_columncxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#rebuild_auto_generated_column(99eba0d3a8372d65).(grn_ctx *ctx, |
| 1146 | grn_obj *column, |
| 1147 | grn_obj *new_table) |
| 1148 | { |
| 1149 | if (grn_logger_pass(ctx, GRN_LOG_NOTICE)) { |
| 1150 | GRN_DEFINE_NAMEcxx . . $ `lib/grn_db.h:90:9`!(column); |
| 1151 | GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, |
| 1152 | GRN_LOG_NOTICE, |
| 1153 | "%s rebuild broken auto generated column: <%.*s>(%u)", |
| 1154 | grn_db_wal_recover_tag, |
| 1155 | name_size, |
| 1156 | name, |
| 1157 | DB_OBJcxx . . $ `lib/grn_db.h:62:9`!(column)->id); |
| 1158 | } |
| 1159 | char name[GRN_TABLE_MAX_KEY_SIZEcxx . . $ `include/groonga/table.h:26:9`!]; |
| 1160 | int name_size = grn_column_name(ctx, column, name, sizeof(name)); |
| 1161 | grn_obj new_name; |
| 1162 | bool need_new_table_unref = false; |
| 1163 | if (new_table) { |
| 1164 | GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&new_name, GRN_OBJ_DO_SHALLOW_COPYcxx . . $ `include/groonga/groonga.h:2732:9`!); |
| 1165 | GRN_TEXT_SETcxx . . $ `include/groonga/groonga.h:2761:9`!(ctx, &new_name, name, name_size); |
| 1166 | } else { |
| 1167 | GRN_TEXT_INITcxx . . $ `include/groonga/groonga.h:2750:9`!(&new_name, 0); |
| 1168 | GRN_TEXT_PUTcxx . . $ `include/groonga/groonga.h:2773:9`!(ctx, |
| 1169 | &new_name, |
| 1170 | grn_db_wal_recovering_name_prefix, |
| 1171 | grn_db_wal_recovering_name_prefix_length); |
| 1172 | GRN_TEXT_PUTcxx . . $ `include/groonga/groonga.h:2773:9`!(ctx, &new_name, name, name_size); |
| 1173 | new_table = grn_ctx_at(ctx, column->headercxx . . $ _grn_obj#header..domain); |
| 1174 | need_new_table_unref = true; |
| 1175 | } |
| 1176 | auto new_column = |
| 1177 | grn_column_create_similar_id_map(ctx, |
| 1178 | new_table, |
| 1179 | GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(&new_name), |
| 1180 | GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(&new_name), |
| 1181 | nullptr, |
| 1182 | column, |
| 1183 | id_map_cxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#id_map_.); |
| 1184 | GRN_OBJ_FINcxx . . $ `include/groonga/groonga.h:958:9`!(ctx, &new_name); |
| 1185 | if (new_column) { |
| 1186 | grn_id_map_add(ctx, |
| 1187 | id_map_cxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#id_map_., |
| 1188 | DB_OBJcxx . . $ `lib/grn_db.h:62:9`!(column)->id, |
| 1189 | DB_OBJcxx . . $ `lib/grn_db.h:62:9`!(new_column)->id); |
| 1190 | grn_obj_unref(ctx, new_column); |
| 1191 | } |
| 1192 | if (need_new_table_unref) { |
| 1193 | grn_obj_unref(ctx, new_table); |
| 1194 | } |
| 1195 | } |
| 1196 | }; |
| 1197 | }; // namespace |
| 1198 | |
| 1199 | static void |
| 1200 | grn_db_wal_recover_copy_renamecxx . . $ grn_db_wal_recover_copy_rename(4f8716b596106d6d).(grn_ctx *ctx, |
| 1201 | grn_db *db, |
| 1202 | grn_hash *broken_table_ids, |
| 1203 | grn_hash *broken_column_ids) |
| 1204 | { |
| 1205 | grn_id_map *id_map = grn_id_map_open(ctx); |
| 1206 | |
| 1207 | GRN_HASH_EACH_BEGINcxx . . $ `include/groonga/hash.h:141:9`!(ctx, broken_table_ids, cursor, entry_id) |
| 1208 | { |
| 1209 | grn_ctx_push_temporary_open_space(ctx); |
| 1210 | grn_id broken_table_id = grn_broken_ids_cursor_getcxx . . $ grn_broken_ids_cursor_get(6f2ad840d1580522).(ctx, cursor); |
| 1211 | grn_obj *broken_table = grn_ctx_at(ctx, broken_table_id); |
| 1212 | if (broken_table) { |
| 1213 | grn_db_wal_recover_copy_tablecxx . . $ grn_db_wal_recover_copy_table(91292fe935144900).(ctx, broken_table, id_map); |
| 1214 | grn_obj_unref(ctx, broken_table); |
| 1215 | } |
| 1216 | GRN_DB_WAL_DISABLE_WAL_BEGINcxx . . $ `lib/grn_db.h:771:9`!(ctx) { grn_ctx_pop_temporary_open_space(ctx); } |
| 1217 | GRN_DB_WAL_DISABLE_WAL_ENDcxx . . $ `lib/grn_db.h:776:9`!(ctx); |
| 1218 | if (ctx->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESS) { |
| 1219 | break; |
| 1220 | } |
| 1221 | } |
| 1222 | GRN_HASH_EACH_ENDcxx . . $ `include/groonga/hash.h:159:9`!(ctx, cursor); |
| 1223 | if (ctx->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESS) { |
| 1224 | goto exit; |
| 1225 | } |
| 1226 | |
| 1227 | GRN_HASH_EACH_BEGINcxx . . $ `include/groonga/hash.h:141:9`!(ctx, broken_table_ids, cursor, entry_id) |
| 1228 | { |
| 1229 | grn_ctx_push_temporary_open_space(ctx); |
| 1230 | grn_id broken_table_id = grn_broken_ids_cursor_getcxx . . $ grn_broken_ids_cursor_get(6f2ad840d1580522).(ctx, cursor); |
| 1231 | grn_obj *broken_table = grn_ctx_at(ctx, broken_table_id); |
| 1232 | if (broken_table) { |
| 1233 | grn_db_wal_recover_copy_non_reference_data_columnscxx . . $ grn_db_wal_recover_copy_non_reference_data_columns(91292fe935144900).(ctx, |
| 1234 | broken_table, |
| 1235 | id_map); |
| 1236 | grn_obj_unref(ctx, broken_table); |
| 1237 | } |
| 1238 | GRN_DB_WAL_DISABLE_WAL_BEGINcxx . . $ `lib/grn_db.h:771:9`!(ctx) { grn_ctx_pop_temporary_open_space(ctx); } |
| 1239 | GRN_DB_WAL_DISABLE_WAL_ENDcxx . . $ `lib/grn_db.h:776:9`!(ctx); |
| 1240 | if (ctx->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESS) { |
| 1241 | break; |
| 1242 | } |
| 1243 | } |
| 1244 | GRN_HASH_EACH_ENDcxx . . $ `include/groonga/hash.h:159:9`!(ctx, cursor); |
| 1245 | if (ctx->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESS) { |
| 1246 | goto exit; |
| 1247 | } |
| 1248 | |
| 1249 | GRN_HASH_EACH_BEGINcxx . . $ `include/groonga/hash.h:141:9`!(ctx, broken_column_ids, cursor, entry_id) |
| 1250 | { |
| 1251 | grn_ctx_push_temporary_open_space(ctx); |
| 1252 | grn_id broken_column_id = grn_broken_ids_cursor_getcxx . . $ grn_broken_ids_cursor_get(6f2ad840d1580522).(ctx, cursor); |
| 1253 | grn_obj *broken_column = grn_ctx_at(ctx, broken_column_id); |
| 1254 | if (broken_column) { |
| 1255 | grn_db_wal_recover_copy_non_reference_data_columncxx . . $ grn_db_wal_recover_copy_non_reference_data_column(ce7f4081a5ab8e24).(ctx, |
| 1256 | broken_column, |
| 1257 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!, |
| 1258 | id_map); |
| 1259 | grn_obj_unref(ctx, broken_column); |
| 1260 | } |
| 1261 | GRN_DB_WAL_DISABLE_WAL_BEGINcxx . . $ `lib/grn_db.h:771:9`!(ctx) { grn_ctx_pop_temporary_open_space(ctx); } |
| 1262 | GRN_DB_WAL_DISABLE_WAL_ENDcxx . . $ `lib/grn_db.h:776:9`!(ctx); |
| 1263 | if (ctx->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESS) { |
| 1264 | break; |
| 1265 | } |
| 1266 | } |
| 1267 | GRN_HASH_EACH_ENDcxx . . $ `include/groonga/hash.h:159:9`!(ctx, cursor); |
| 1268 | if (ctx->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESS) { |
| 1269 | goto exit; |
| 1270 | } |
| 1271 | |
| 1272 | GRN_HASH_EACH_BEGINcxx . . $ `include/groonga/hash.h:141:9`!(ctx, broken_table_ids, cursor, entry_id) |
| 1273 | { |
| 1274 | grn_ctx_push_temporary_open_space(ctx); |
| 1275 | grn_id broken_table_id = grn_broken_ids_cursor_getcxx . . $ grn_broken_ids_cursor_get(6f2ad840d1580522).(ctx, cursor); |
| 1276 | grn_obj *broken_table = grn_ctx_at(ctx, broken_table_id); |
| 1277 | if (broken_table) { |
| 1278 | grn_db_wal_recover_copy_reference_data_columnscxx . . $ grn_db_wal_recover_copy_reference_data_columns(91292fe935144900).(ctx, broken_table, id_map); |
| 1279 | grn_obj_unref(ctx, broken_table); |
| 1280 | } |
| 1281 | GRN_DB_WAL_DISABLE_WAL_BEGINcxx . . $ `lib/grn_db.h:771:9`!(ctx) { grn_ctx_pop_temporary_open_space(ctx); } |
| 1282 | GRN_DB_WAL_DISABLE_WAL_ENDcxx . . $ `lib/grn_db.h:776:9`!(ctx); |
| 1283 | if (ctx->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESS) { |
| 1284 | break; |
| 1285 | } |
| 1286 | } |
| 1287 | GRN_HASH_EACH_ENDcxx . . $ `include/groonga/hash.h:159:9`!(ctx, cursor); |
| 1288 | if (ctx->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESS) { |
| 1289 | goto exit; |
| 1290 | } |
| 1291 | |
| 1292 | GRN_HASH_EACH_BEGINcxx . . $ `include/groonga/hash.h:141:9`!(ctx, broken_column_ids, cursor, entry_id) |
| 1293 | { |
| 1294 | grn_ctx_push_temporary_open_space(ctx); |
| 1295 | grn_id broken_column_id = grn_broken_ids_cursor_getcxx . . $ grn_broken_ids_cursor_get(6f2ad840d1580522).(ctx, cursor); |
| 1296 | grn_obj *broken_column = grn_ctx_at(ctx, broken_column_id); |
| 1297 | if (broken_column) { |
| 1298 | grn_db_wal_recover_copy_reference_data_columncxx . . $ grn_db_wal_recover_copy_reference_data_column(ce7f4081a5ab8e24).(ctx, |
| 1299 | broken_column, |
| 1300 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!, |
| 1301 | id_map); |
| 1302 | grn_obj_unref(ctx, broken_column); |
| 1303 | } |
| 1304 | GRN_DB_WAL_DISABLE_WAL_BEGINcxx . . $ `lib/grn_db.h:771:9`!(ctx) { grn_ctx_pop_temporary_open_space(ctx); } |
| 1305 | GRN_DB_WAL_DISABLE_WAL_ENDcxx . . $ `lib/grn_db.h:776:9`!(ctx); |
| 1306 | if (ctx->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESS) { |
| 1307 | break; |
| 1308 | } |
| 1309 | } |
| 1310 | GRN_HASH_EACH_ENDcxx . . $ `include/groonga/hash.h:159:9`!(ctx, cursor); |
| 1311 | if (ctx->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESS) { |
| 1312 | goto exit; |
| 1313 | } |
| 1314 | |
| 1315 | { |
| 1316 | DBWALCopyRecoverercxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer# recoverercxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#DBWALCopyRecoverer(7303a3526d3893cb).(ctx, |
| 1317 | broken_table_ids, |
| 1318 | broken_column_ids, |
| 1319 | id_map); |
| 1320 | recoverer.rebuild_auto_generated_columnscxx . . $ `$anonymous_namespace_lib/db_wal_recover.cpp`/DBWALCopyRecoverer#rebuild_auto_generated_columns(49f6e7a06ebc5aa8).(); |
| 1321 | } |
| 1322 | if (ctx->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESS) { |
| 1323 | goto exit; |
| 1324 | } |
| 1325 | |
| 1326 | GRN_HASH_EACH_BEGINcxx . . $ `include/groonga/hash.h:141:9`!(ctx, broken_column_ids, cursor, entry_id) |
| 1327 | { |
| 1328 | grn_ctx_push_temporary_open_space(ctx); |
| 1329 | grn_id broken_column_id = grn_broken_ids_cursor_getcxx . . $ grn_broken_ids_cursor_get(6f2ad840d1580522).(ctx, cursor); |
| 1330 | grn_db_wal_recover_rename_columncxx . . $ grn_db_wal_recover_rename_column(41f7f642728b895b).(ctx, db, broken_column_id, id_map); |
| 1331 | GRN_DB_WAL_DISABLE_WAL_BEGINcxx . . $ `lib/grn_db.h:771:9`!(ctx) { grn_ctx_pop_temporary_open_space(ctx); } |
| 1332 | GRN_DB_WAL_DISABLE_WAL_ENDcxx . . $ `lib/grn_db.h:776:9`!(ctx); |
| 1333 | if (ctx->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESS) { |
| 1334 | break; |
| 1335 | } |
| 1336 | } |
| 1337 | GRN_HASH_EACH_ENDcxx . . $ `include/groonga/hash.h:159:9`!(ctx, cursor); |
| 1338 | if (ctx->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESS) { |
| 1339 | goto exit; |
| 1340 | } |
| 1341 | |
| 1342 | GRN_HASH_EACH_BEGINcxx . . $ `include/groonga/hash.h:141:9`!(ctx, broken_table_ids, cursor, entry_id) |
| 1343 | { |
| 1344 | grn_ctx_push_temporary_open_space(ctx); |
| 1345 | grn_id broken_table_id = grn_broken_ids_cursor_getcxx . . $ grn_broken_ids_cursor_get(6f2ad840d1580522).(ctx, cursor); |
| 1346 | grn_db_wal_recover_rename_tablecxx . . $ grn_db_wal_recover_rename_table(41f7f642728b895b).(ctx, db, broken_table_id, id_map); |
| 1347 | GRN_DB_WAL_DISABLE_WAL_BEGINcxx . . $ `lib/grn_db.h:771:9`!(ctx) { grn_ctx_pop_temporary_open_space(ctx); } |
| 1348 | GRN_DB_WAL_DISABLE_WAL_ENDcxx . . $ `lib/grn_db.h:776:9`!(ctx); |
| 1349 | if (ctx->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESS) { |
| 1350 | break; |
| 1351 | } |
| 1352 | } |
| 1353 | GRN_HASH_EACH_ENDcxx . . $ `include/groonga/hash.h:159:9`!(ctx, cursor); |
| 1354 | if (ctx->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESS) { |
| 1355 | goto exit; |
| 1356 | } |
| 1357 | |
| 1358 | exit: |
| 1359 | grn_id_map_close(ctx, id_map); |
| 1360 | } |
| 1361 | |
| 1362 | static bool |
| 1363 | grn_db_wal_recover_is_target_objectcxx . . $ grn_db_wal_recover_is_target_object(a5760e5c319a06ee).(grn_ctx *ctx, grn_obj *object) |
| 1364 | { |
| 1365 | if (!object) { |
| 1366 | return false; |
| 1367 | } |
| 1368 | |
| 1369 | if (grn_obj_is_table(ctx, object)) { |
| 1370 | return true; |
| 1371 | } |
| 1372 | if (grn_obj_is_column(ctx, object)) { |
| 1373 | return true; |
| 1374 | } |
| 1375 | return false; |
| 1376 | } |
| 1377 | |
| 1378 | void |
| 1379 | grn_db_wal_recovercxx . . $ grn_db_wal_recover(ea3523c40d20cded).(grn_ctx *ctx, grn_db *db) |
| 1380 | { |
| 1381 | const char *tag = grn_db_wal_recover_tagcxx . . $ grn_db_wal_recover_tag.; |
| 1382 | |
| 1383 | if (GRN_CTX_GET_WAL_ROLEcxx . . $ `lib/grn_ctx_impl.h:233:9`!(ctx) != GRN_WAL_ROLE_PRIMARY) { |
| 1384 | return; |
| 1385 | } |
| 1386 | |
| 1387 | GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, GRN_LOG_DEBUG, "%s recover DB keys", tag); |
| 1388 | switch (db->keyscxx . . $ _grn_db#keys.->headercxx . . $ _grn_obj#header..type) { |
| 1389 | case GRN_TABLE_PAT_KEYcxx . . $ `include/groonga/groonga.h:896:9`!: |
| 1390 | grn_pat_wal_recover(ctx, (grn_pat *)(db->keyscxx . . $ _grn_db#keys.)); |
| 1391 | break; |
| 1392 | case GRN_TABLE_DAT_KEYcxx . . $ `include/groonga/groonga.h:897:9`!: |
| 1393 | grn_dat_wal_recover(ctx, (grn_dat *)(db->keyscxx . . $ _grn_db#keys.)); |
| 1394 | break; |
| 1395 | default: |
| 1396 | break; |
| 1397 | } |
| 1398 | if (ctx->rccxx . . $ _grn_ctx#rc. == GRN_SUCCESS) { |
| 1399 | GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, GRN_LOG_DEBUG, "%s succeeded to recover DB keys", tag); |
| 1400 | } else { |
| 1401 | ERRCLRcxx . . $ `lib/grn_error.h:37:9`!(ctx); |
| 1402 | grn_db_wal_recover_keyscxx . . $ grn_db_wal_recover_keys(ea3523c40d20cded).(ctx, db); |
| 1403 | if (ctx->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESS) { |
| 1404 | GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, |
| 1405 | GRN_LOG_ERROR, |
| 1406 | "%s failed to recover DB keys: %s", |
| 1407 | tag, |
| 1408 | ctx->errbuf); |
| 1409 | return; |
| 1410 | } |
| 1411 | } |
| 1412 | |
| 1413 | GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, GRN_LOG_DEBUG, "%s recover DB specs", tag); |
| 1414 | grn_ja_wal_recover(ctx, db->specscxx . . $ _grn_db#specs.); |
| 1415 | if (ctx->rccxx . . $ _grn_ctx#rc. == GRN_SUCCESS) { |
| 1416 | GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, GRN_LOG_DEBUG, "%s succeeded to recover DB specs", tag); |
| 1417 | } else { |
| 1418 | GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, |
| 1419 | GRN_LOG_ERROR, |
| 1420 | "%s failed to recover DB specs: %s", |
| 1421 | tag, |
| 1422 | ctx->errbuf); |
| 1423 | return; |
| 1424 | } |
| 1425 | |
| 1426 | GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, GRN_LOG_DEBUG, "%s recover DB config", tag); |
| 1427 | grn_hash_wal_recover(ctx, db->configcxx . . $ _grn_db#config.); |
| 1428 | if (ctx->rccxx . . $ _grn_ctx#rc. == GRN_SUCCESS) { |
| 1429 | GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, GRN_LOG_DEBUG, "%s succeeded to recover DB config", tag); |
| 1430 | } else { |
| 1431 | GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, |
| 1432 | GRN_LOG_ERROR, |
| 1433 | "%s failed to recover DB config: %s", |
| 1434 | tag, |
| 1435 | ctx->errbuf); |
| 1436 | return; |
| 1437 | } |
| 1438 | |
| 1439 | GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, GRN_LOG_DEBUG, "%s recover DB options", tag); |
| 1440 | grn_options_wal_recover(ctx, db->optionscxx . . $ _grn_db#options.); |
| 1441 | if (ctx->rccxx . . $ _grn_ctx#rc. == GRN_SUCCESS) { |
| 1442 | GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, GRN_LOG_DEBUG, "%s succeeded to recover DB options", tag); |
| 1443 | } else { |
| 1444 | GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, |
| 1445 | GRN_LOG_ERROR, |
| 1446 | "%s failed to recover DB options: %s", |
| 1447 | tag, |
| 1448 | ctx->errbuf); |
| 1449 | return; |
| 1450 | } |
| 1451 | |
| 1452 | grn_db_wal_recover_remove_recovering_objectscxx . . $ grn_db_wal_recover_remove_recovering_objects(ea3523c40d20cded).(ctx, db); |
| 1453 | grn_db_wal_recover_remove_broken_objectscxx . . $ grn_db_wal_recover_remove_broken_objects(ea3523c40d20cded).(ctx, db); |
| 1454 | |
| 1455 | grn_hash *broken_table_ids = grn_broken_ids_opencxx . . $ grn_broken_ids_open(ffed87ac09259372).(ctx); |
| 1456 | grn_hash *broken_column_ids = grn_broken_ids_opencxx . . $ grn_broken_ids_open(ffed87ac09259372).(ctx); |
| 1457 | GRN_TABLE_EACH_BEGIN_FLAGScxx . . $ `include/groonga/table.h:631:9`!(ctx, db->keys, cursor, id, GRN_CURSOR_BY_IDcxx . . $ `include/groonga/table.h:280:9`!) |
| 1458 | { |
| 1459 | if (grn_id_is_builtin(ctx, id)) { |
| 1460 | continue; |
| 1461 | } |
| 1462 | |
| 1463 | grn_ctx_push_temporary_open_space(ctx); |
| 1464 | grn_obj *object = grn_ctx_at(ctx, id); |
| 1465 | if (grn_ctx_is_removing(ctx, id)) { |
| 1466 | grn_db_wal_recover_remove_objectcxx . . $ grn_db_wal_recover_remove_object(f492fda562814758).(ctx, db, object, id); |
| 1467 | } else if (grn_db_wal_recover_is_target_objectcxx . . $ grn_db_wal_recover_is_target_object(a5760e5c319a06ee).(ctx, object)) { |
| 1468 | bool is_table = false; |
| 1469 | bool is_column = false; |
| 1470 | if (grn_logger_pass(ctx, GRN_LOG_DEBUG)) { |
| 1471 | GRN_DEFINE_NAMEcxx . . $ `lib/grn_db.h:90:9`!(object); |
| 1472 | GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, |
| 1473 | GRN_LOG_DEBUG, |
| 1474 | "%s recover %s: <%.*s>(%u)", |
| 1475 | tag, |
| 1476 | grn_obj_type_to_string(object->header.type), |
| 1477 | name_size, |
| 1478 | name, |
| 1479 | DB_OBJcxx . . $ `lib/grn_db.h:62:9`!(object)->id); |
| 1480 | } |
| 1481 | switch (object->headercxx . . $ _grn_obj#header..type) { |
| 1482 | case GRN_TABLE_HASH_KEYcxx . . $ `include/groonga/groonga.h:895:9`!: |
| 1483 | is_table = true; |
| 1484 | grn_hash_wal_recover(ctx, (grn_hash *)object); |
| 1485 | break; |
| 1486 | case GRN_TABLE_PAT_KEYcxx . . $ `include/groonga/groonga.h:896:9`!: |
| 1487 | is_table = true; |
| 1488 | grn_pat_wal_recover(ctx, (grn_pat *)object); |
| 1489 | break; |
| 1490 | case GRN_TABLE_DAT_KEYcxx . . $ `include/groonga/groonga.h:897:9`!: |
| 1491 | is_table = true; |
| 1492 | grn_dat_wal_recover(ctx, (grn_dat *)object); |
| 1493 | break; |
| 1494 | case GRN_TABLE_NO_KEYcxx . . $ `include/groonga/groonga.h:898:9`!: |
| 1495 | is_table = true; |
| 1496 | grn_array_wal_recover(ctx, (grn_array *)object); |
| 1497 | break; |
| 1498 | case GRN_COLUMN_FIX_SIZEcxx . . $ `include/groonga/groonga.h:900:9`!: |
| 1499 | is_column = true; |
| 1500 | grn_ra_wal_recover(ctx, (grn_ra *)object); |
| 1501 | break; |
| 1502 | case GRN_COLUMN_VAR_SIZEcxx . . $ `include/groonga/groonga.h:901:9`!: |
| 1503 | is_column = true; |
| 1504 | grn_ja_wal_recover(ctx, (grn_ja *)object); |
| 1505 | break; |
| 1506 | case GRN_COLUMN_INDEXcxx . . $ `include/groonga/groonga.h:902:9`!: |
| 1507 | is_column = true; |
| 1508 | grn_ii_wal_recover(ctx, (grn_ii *)object); |
| 1509 | break; |
| 1510 | default: |
| 1511 | break; |
| 1512 | } |
| 1513 | if (ctx->rccxx . . $ _grn_ctx#rc. == GRN_SUCCESS) { |
| 1514 | if (grn_logger_pass(ctx, GRN_LOG_DEBUG)) { |
| 1515 | GRN_DEFINE_NAMEcxx . . $ `lib/grn_db.h:90:9`!(object); |
| 1516 | GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, |
| 1517 | GRN_LOG_DEBUG, |
| 1518 | "%s succeeded to recover %s: <%.*s>(%u)", |
| 1519 | tag, |
| 1520 | grn_obj_type_to_string(object->header.type), |
| 1521 | name_size, |
| 1522 | name, |
| 1523 | DB_OBJcxx . . $ `lib/grn_db.h:62:9`!(object)->id); |
| 1524 | } |
| 1525 | } else { |
| 1526 | if (grn_logger_pass(ctx, GRN_LOG_DEBUG)) { |
| 1527 | GRN_DEFINE_NAMEcxx . . $ `lib/grn_db.h:90:9`!(object); |
| 1528 | GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, |
| 1529 | GRN_LOG_DEBUG, |
| 1530 | "%s failed to recover %s: <%.*s>(%u)", |
| 1531 | tag, |
| 1532 | grn_obj_type_to_string(object->header.type), |
| 1533 | name_size, |
| 1534 | name, |
| 1535 | DB_OBJcxx . . $ `lib/grn_db.h:62:9`!(object)->id); |
| 1536 | } |
| 1537 | if (is_table) { |
| 1538 | grn_broken_ids_addcxx . . $ grn_broken_ids_add(e1b55fed33f28ff6).(ctx, broken_table_ids, id); |
| 1539 | } else if (is_column) { |
| 1540 | grn_broken_ids_addcxx . . $ grn_broken_ids_add(e1b55fed33f28ff6).(ctx, broken_column_ids, id); |
| 1541 | } |
| 1542 | ERRCLRcxx . . $ `lib/grn_error.h:37:9`!(ctx); |
| 1543 | } |
| 1544 | } |
| 1545 | GRN_DB_WAL_DISABLE_WAL_BEGINcxx . . $ `lib/grn_db.h:771:9`!(ctx) |
| 1546 | { |
| 1547 | if (object) { |
| 1548 | grn_obj_unref(ctx, object); |
| 1549 | } |
| 1550 | grn_ctx_pop_temporary_open_space(ctx); |
| 1551 | } |
| 1552 | GRN_DB_WAL_DISABLE_WAL_ENDcxx . . $ `lib/grn_db.h:776:9`!(ctx); |
| 1553 | if (ctx->rccxx . . $ _grn_ctx#rc. != GRN_SUCCESS) { |
| 1554 | break; |
| 1555 | } |
| 1556 | } |
| 1557 | GRN_TABLE_EACH_ENDcxx . . $ `include/groonga/table.h:665:9`!(ctx, cursor); |
| 1558 | |
| 1559 | grn_db_wal_recover_collect_related_broken_object_idscxx . . $ grn_db_wal_recover_collect_related_broken_object_ids(4f8716b596106d6d).(ctx, |
| 1560 | db, |
| 1561 | broken_table_ids, |
| 1562 | broken_column_ids); |
| 1563 | |
| 1564 | grn_db_wal_recover_copy_renamecxx . . $ grn_db_wal_recover_copy_rename(4f8716b596106d6d).(ctx, db, broken_table_ids, broken_column_ids); |
| 1565 | |
| 1566 | grn_broken_ids_closecxx . . $ grn_broken_ids_close(57c8ed80822320b7).(ctx, broken_table_ids); |
| 1567 | grn_broken_ids_closecxx . . $ grn_broken_ids_close(57c8ed80822320b7).(ctx, broken_column_ids); |
| 1568 | |
| 1569 | grn_db_wal_recover_remove_recovering_objectscxx . . $ grn_db_wal_recover_remove_recovering_objects(ea3523c40d20cded).(ctx, db); |
| 1570 | grn_db_wal_recover_remove_broken_objectscxx . . $ grn_db_wal_recover_remove_broken_objects(ea3523c40d20cded).(ctx, db); |
| 1571 | |
| 1572 | if (ctx->rccxx . . $ _grn_ctx#rc. == GRN_SUCCESS) { |
| 1573 | GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, GRN_LOG_DEBUG, "%s succeeded to recover", tag); |
| 1574 | grn_obj_flush(ctx, (grn_obj *)db); |
| 1575 | } else { |
| 1576 | GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, GRN_LOG_ERROR, "%s failed to recover: %s", tag, ctx->errbuf); |
| 1577 | } |
| 1578 | } |