4 Copyright (C) Andrew Tridgell 2007
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, see <http://www.gnu.org/licenses/>.
20 #include "system/network.h"
21 #include "system/filesys.h"
22 #include "system/wait.h"
27 #include "lib/tdb_wrap/tdb_wrap.h"
28 #include "lib/util/dlinklist.h"
29 #include "lib/util/debug.h"
31 #include "ctdb_private.h"
33 #include "common/rb_tree.h"
34 #include "common/common.h"
35 #include "common/logging.h"
38 * Cancel a transaction on database
40 static int db_transaction_cancel_handler(struct ctdb_db_context
*ctdb_db
,
45 tdb_add_flags(ctdb_db
->ltdb
->tdb
, TDB_NOLOCK
);
46 ret
= tdb_transaction_cancel(ctdb_db
->ltdb
->tdb
);
48 DEBUG(DEBUG_ERR
, ("Failed to cancel transaction for db %s\n",
51 tdb_remove_flags(ctdb_db
->ltdb
->tdb
, TDB_NOLOCK
);
56 * Start a transaction on database
58 static int db_transaction_start_handler(struct ctdb_db_context
*ctdb_db
,
61 bool freeze_transaction_started
= *(bool *)private_data
;
64 tdb_add_flags(ctdb_db
->ltdb
->tdb
, TDB_NOLOCK
);
65 if (freeze_transaction_started
) {
66 ret
= tdb_transaction_cancel(ctdb_db
->ltdb
->tdb
);
69 ("Failed to cancel transaction for db %s\n",
73 ret
= tdb_transaction_start(ctdb_db
->ltdb
->tdb
);
74 tdb_remove_flags(ctdb_db
->ltdb
->tdb
, TDB_NOLOCK
);
76 DEBUG(DEBUG_ERR
, ("Failed to start transaction for db %s\n",
84 * Commit a transaction on database
86 static int db_transaction_commit_handler(struct ctdb_db_context
*ctdb_db
,
89 unsigned int healthy_nodes
= *(unsigned int *)private_data
;
92 tdb_add_flags(ctdb_db
->ltdb
->tdb
, TDB_NOLOCK
);
93 ret
= tdb_transaction_commit(ctdb_db
->ltdb
->tdb
);
94 tdb_remove_flags(ctdb_db
->ltdb
->tdb
, TDB_NOLOCK
);
96 DEBUG(DEBUG_ERR
, ("Failed to commit transaction for db %s\n",
101 ret
= ctdb_update_persistent_health(ctdb_db
->ctdb
, ctdb_db
, NULL
,
104 DEBUG(DEBUG_ERR
, ("Failed to update persistent health for db %s\n",
110 /* a list of control requests waiting for db freeze */
111 struct ctdb_db_freeze_waiter
{
112 struct ctdb_db_freeze_waiter
*next
, *prev
;
113 struct ctdb_context
*ctdb
;
118 /* a handle to a db freeze lock child process */
119 struct ctdb_db_freeze_handle
{
120 struct ctdb_db_context
*ctdb_db
;
121 struct lock_request
*lreq
;
122 struct ctdb_db_freeze_waiter
*waiters
;
126 * Called when freeing database freeze handle
128 static int ctdb_db_freeze_handle_destructor(struct ctdb_db_freeze_handle
*h
)
130 struct ctdb_db_context
*ctdb_db
= h
->ctdb_db
;
132 DEBUG(DEBUG_ERR
, ("Release freeze handle for db %s\n",
135 /* Cancel any pending transactions */
136 if (ctdb_db
->freeze_transaction_started
) {
137 db_transaction_cancel_handler(ctdb_db
, NULL
);
138 ctdb_db
->freeze_transaction_started
= false;
140 ctdb_db
->freeze_mode
= CTDB_FREEZE_NONE
;
141 ctdb_db
->freeze_handle
= NULL
;
143 /* Clear invalid records flag */
144 ctdb_db
->invalid_records
= false;
146 talloc_free(h
->lreq
);
151 * Called when a database is frozen
153 static void ctdb_db_freeze_handler(void *private_data
, bool locked
)
155 struct ctdb_db_freeze_handle
*h
= talloc_get_type_abort(
156 private_data
, struct ctdb_db_freeze_handle
);
157 struct ctdb_db_freeze_waiter
*w
;
159 if (h
->ctdb_db
->freeze_mode
== CTDB_FREEZE_FROZEN
) {
160 DEBUG(DEBUG_ERR
, ("Freeze db child died - unfreezing\n"));
161 h
->ctdb_db
->freeze_mode
= CTDB_FREEZE_NONE
;
167 DEBUG(DEBUG_ERR
, ("Failed to get db lock for %s\n",
168 h
->ctdb_db
->db_name
));
169 h
->ctdb_db
->freeze_mode
= CTDB_FREEZE_NONE
;
174 h
->ctdb_db
->freeze_mode
= CTDB_FREEZE_FROZEN
;
176 /* notify the waiters */
177 while ((w
= h
->waiters
) != NULL
) {
179 DLIST_REMOVE(h
->waiters
, w
);
185 * Start freeze process for a database
187 static void ctdb_start_db_freeze(struct ctdb_db_context
*ctdb_db
)
189 struct ctdb_db_freeze_handle
*h
;
191 if (ctdb_db
->freeze_mode
== CTDB_FREEZE_FROZEN
) {
195 if (ctdb_db
->freeze_handle
!= NULL
) {
199 DEBUG(DEBUG_ERR
, ("Freeze db: %s\n", ctdb_db
->db_name
));
201 ctdb_stop_vacuuming(ctdb_db
->ctdb
);
203 h
= talloc_zero(ctdb_db
, struct ctdb_db_freeze_handle
);
204 CTDB_NO_MEMORY_FATAL(ctdb_db
->ctdb
, h
);
206 h
->ctdb_db
= ctdb_db
;
207 h
->lreq
= ctdb_lock_db(h
, ctdb_db
, false, ctdb_db_freeze_handler
, h
);
208 CTDB_NO_MEMORY_FATAL(ctdb_db
->ctdb
, h
->lreq
);
209 talloc_set_destructor(h
, ctdb_db_freeze_handle_destructor
);
211 ctdb_db
->freeze_handle
= h
;
212 ctdb_db
->freeze_mode
= CTDB_FREEZE_PENDING
;
216 * Reply to a waiter for db freeze
218 static int ctdb_db_freeze_waiter_destructor(struct ctdb_db_freeze_waiter
*w
)
220 /* 'c' pointer is talloc_memdup(), so cannot use talloc_get_type */
221 struct ctdb_req_control_old
*c
=
222 (struct ctdb_req_control_old
*)w
->private_data
;
224 ctdb_request_control_reply(w
->ctdb
, c
, NULL
, w
->status
, NULL
);
231 int32_t ctdb_control_db_freeze(struct ctdb_context
*ctdb
,
232 struct ctdb_req_control_old
*c
,
236 struct ctdb_db_context
*ctdb_db
;
237 struct ctdb_db_freeze_waiter
*w
;
239 ctdb_db
= find_ctdb_db(ctdb
, db_id
);
240 if (ctdb_db
== NULL
) {
241 DEBUG(DEBUG_ERR
, ("Freeze db for unknown dbid 0x%08x\n", db_id
));
245 if (ctdb_db
->freeze_mode
== CTDB_FREEZE_FROZEN
) {
246 DEBUG(DEBUG_ERR
, ("Freeze db: %s frozen\n", ctdb_db
->db_name
));
250 ctdb_start_db_freeze(ctdb_db
);
252 /* add ourselves to the list of waiters */
253 w
= talloc(ctdb_db
->freeze_handle
, struct ctdb_db_freeze_waiter
);
254 CTDB_NO_MEMORY(ctdb
, w
);
256 w
->private_data
= talloc_steal(w
, c
);
258 talloc_set_destructor(w
, ctdb_db_freeze_waiter_destructor
);
259 DLIST_ADD(ctdb_db
->freeze_handle
->waiters
, w
);
268 int32_t ctdb_control_db_thaw(struct ctdb_context
*ctdb
, uint32_t db_id
)
270 struct ctdb_db_context
*ctdb_db
;
272 ctdb_db
= find_ctdb_db(ctdb
, db_id
);
273 if (ctdb_db
== NULL
) {
274 DEBUG(DEBUG_ERR
, ("Thaw db for unknown dbid 0x%08x\n", db_id
));
278 DEBUG(DEBUG_ERR
, ("Thaw db: %s generation %u\n", ctdb_db
->db_name
,
279 ctdb_db
->generation
));
281 TALLOC_FREE(ctdb_db
->freeze_handle
);
282 ctdb_call_resend_db(ctdb_db
);
288 a list of control requests waiting for a freeze lock child to get
291 struct ctdb_freeze_waiter
{
292 struct ctdb_freeze_waiter
*next
, *prev
;
293 struct ctdb_context
*ctdb
;
294 struct ctdb_req_control_old
*c
;
298 /* a handle to a freeze lock child process */
299 struct ctdb_freeze_handle
{
300 struct ctdb_context
*ctdb
;
301 unsigned int num_total
, num_locked
, num_failed
;
302 struct ctdb_freeze_waiter
*waiters
;
305 static int db_thaw(struct ctdb_db_context
*ctdb_db
, void *private_data
)
307 talloc_free(ctdb_db
->freeze_handle
);
312 destroy a freeze handle
314 static int ctdb_freeze_handle_destructor(struct ctdb_freeze_handle
*h
)
316 struct ctdb_context
*ctdb
= h
->ctdb
;
318 DEBUG(DEBUG_ERR
,("Release freeze handle\n"));
320 /* cancel any pending transactions */
321 if (ctdb
->freeze_transaction_started
) {
322 ctdb_db_iterator(ctdb
, db_transaction_cancel_handler
, NULL
);
323 ctdb
->freeze_transaction_started
= false;
326 ctdb_db_iterator(ctdb
, db_thaw
, NULL
);
328 ctdb
->freeze_mode
= CTDB_FREEZE_NONE
;
329 ctdb
->freeze_handle
= NULL
;
335 called when the child writes its status to us
337 static void ctdb_freeze_lock_handler(void *private_data
, bool locked
)
339 struct ctdb_freeze_handle
*h
= talloc_get_type_abort(private_data
,
340 struct ctdb_freeze_handle
);
341 struct ctdb_freeze_waiter
*w
;
343 if (h
->ctdb
->freeze_mode
== CTDB_FREEZE_FROZEN
) {
344 DEBUG(DEBUG_INFO
,("freeze child died - unfreezing\n"));
350 DEBUG(DEBUG_ERR
,("Failed to get locks in ctdb_freeze_child\n"));
351 /* we didn't get the locks - destroy the handle */
356 h
->ctdb
->freeze_mode
= CTDB_FREEZE_FROZEN
;
358 /* notify the waiters */
359 if (h
!= h
->ctdb
->freeze_handle
) {
360 DEBUG(DEBUG_ERR
,("lockwait finished but h is not linked\n"));
362 while ((w
= h
->waiters
)) {
364 DLIST_REMOVE(h
->waiters
, w
);
370 * When single database is frozen
372 static int db_freeze_waiter_destructor(struct ctdb_db_freeze_waiter
*w
)
374 struct ctdb_freeze_handle
*h
= talloc_get_type_abort(
375 w
->private_data
, struct ctdb_freeze_handle
);
377 if (w
->status
== 0) {
383 /* Call ctdb_freeze_lock_handler() only when the status of all
384 * databases is known.
386 if (h
->num_locked
+ h
->num_failed
== h
->num_total
) {
389 if (h
->num_locked
== h
->num_total
) {
394 ctdb_freeze_lock_handler(h
, locked
);
400 * Invalidate the records in the database.
401 * This only applies to volatile databases.
403 static int db_invalidate(struct ctdb_db_context
*ctdb_db
, void *private_data
)
405 if (ctdb_db_volatile(ctdb_db
)) {
406 ctdb_db
->invalid_records
= true;
413 * Count the number of databases
415 static int db_count(struct ctdb_db_context
*ctdb_db
, void *private_data
)
417 unsigned int *count
= (unsigned int *)private_data
;
425 * Freeze a single database
427 static int db_freeze(struct ctdb_db_context
*ctdb_db
, void *private_data
)
429 struct ctdb_freeze_handle
*h
= talloc_get_type_abort(
430 private_data
, struct ctdb_freeze_handle
);
431 struct ctdb_db_freeze_waiter
*w
;
433 ctdb_start_db_freeze(ctdb_db
);
435 w
= talloc(ctdb_db
->freeze_handle
, struct ctdb_db_freeze_waiter
);
436 CTDB_NO_MEMORY(h
->ctdb
, w
);
440 talloc_set_destructor(w
, db_freeze_waiter_destructor
);
442 if (ctdb_db
->freeze_mode
== CTDB_FREEZE_FROZEN
) {
443 /* Early return if already frozen */
449 DLIST_ADD(ctdb_db
->freeze_handle
->waiters
, w
);
455 start the freeze process for all databases
456 This is only called from ctdb_control_freeze(), which is called
457 only on node becoming INACTIVE. So mark the records invalid.
459 static void ctdb_start_freeze(struct ctdb_context
*ctdb
)
461 struct ctdb_freeze_handle
*h
;
464 ctdb_db_iterator(ctdb
, db_invalidate
, NULL
);
466 if (ctdb
->freeze_mode
== CTDB_FREEZE_FROZEN
) {
467 unsigned int count
= 0;
470 * Check if all the databases are frozen
472 * It's possible that the databases can get attached after
473 * initial freeze. This typically happens during startup as
474 * CTDB will only attach persistent databases and go in to
475 * startup freeze. The recovery master during recovery will
476 * attach all the missing databases.
479 h
= ctdb
->freeze_handle
;
481 ctdb
->freeze_mode
= CTDB_FREEZE_NONE
;
485 ret
= ctdb_db_iterator(ctdb
, db_count
, &count
);
487 TALLOC_FREE(ctdb
->freeze_handle
);
488 ctdb
->freeze_mode
= CTDB_FREEZE_NONE
;
492 if (count
!= h
->num_total
) {
493 DEBUG(DEBUG_ERR
, ("Freeze all: incremental\n"));
495 h
->num_total
= count
;
499 ctdb
->freeze_mode
= CTDB_FREEZE_PENDING
;
501 ret
= ctdb_db_iterator(ctdb
, db_freeze
, h
);
503 TALLOC_FREE(ctdb
->freeze_handle
);
504 ctdb
->freeze_mode
= CTDB_FREEZE_NONE
;
510 if (ctdb
->freeze_handle
!= NULL
) {
511 /* already trying to freeze */
515 DEBUG(DEBUG_ERR
, ("Freeze all\n"));
517 /* Stop any vacuuming going on: we don't want to wait. */
518 ctdb_stop_vacuuming(ctdb
);
520 /* create freeze lock children for each database */
521 h
= talloc_zero(ctdb
, struct ctdb_freeze_handle
);
522 CTDB_NO_MEMORY_FATAL(ctdb
, h
);
524 talloc_set_destructor(h
, ctdb_freeze_handle_destructor
);
525 ctdb
->freeze_handle
= h
;
527 ret
= ctdb_db_iterator(ctdb
, db_count
, &h
->num_total
);
533 ctdb
->freeze_mode
= CTDB_FREEZE_PENDING
;
535 ret
= ctdb_db_iterator(ctdb
, db_freeze
, h
);
541 if (h
->num_total
== 0) {
542 ctdb
->freeze_mode
= CTDB_FREEZE_FROZEN
;
547 destroy a waiter for a freeze mode change
549 static int ctdb_freeze_waiter_destructor(struct ctdb_freeze_waiter
*w
)
551 ctdb_request_control_reply(w
->ctdb
, w
->c
, NULL
, w
->status
, NULL
);
556 freeze all the databases
557 This control is only used when freezing database on node becoming INACTIVE.
558 So mark the records invalid in ctdb_start_freeze().
560 int32_t ctdb_control_freeze(struct ctdb_context
*ctdb
,
561 struct ctdb_req_control_old
*c
, bool *async_reply
)
563 struct ctdb_freeze_waiter
*w
;
565 ctdb_start_freeze(ctdb
);
567 if (ctdb
->freeze_mode
== CTDB_FREEZE_FROZEN
) {
568 DEBUG(DEBUG_ERR
, ("Freeze all: frozen\n"));
569 /* we're already frozen */
573 if (ctdb
->freeze_handle
== NULL
) {
574 DEBUG(DEBUG_ERR
,("No freeze lock handle when adding a waiter\n"));
578 /* If there are no databases, we are done. */
579 if (ctdb
->freeze_handle
->num_total
== 0) {
583 /* add ourselves to list of waiters */
584 w
= talloc(ctdb
->freeze_handle
, struct ctdb_freeze_waiter
);
585 CTDB_NO_MEMORY(ctdb
, w
);
587 w
->c
= talloc_steal(w
, c
);
589 talloc_set_destructor(w
, ctdb_freeze_waiter_destructor
);
590 DLIST_ADD(ctdb
->freeze_handle
->waiters
, w
);
592 /* we won't reply till later */
598 static int db_freeze_block(struct ctdb_db_context
*ctdb_db
, void *private_data
)
600 struct tevent_context
*ev
= (struct tevent_context
*)private_data
;
602 ctdb_start_db_freeze(ctdb_db
);
604 while (ctdb_db
->freeze_mode
== CTDB_FREEZE_PENDING
) {
605 tevent_loop_once(ev
);
608 if (ctdb_db
->freeze_mode
!= CTDB_FREEZE_FROZEN
) {
616 block until we are frozen, used during daemon startup
618 bool ctdb_blocking_freeze(struct ctdb_context
*ctdb
)
622 ret
= ctdb_db_iterator(ctdb
, db_freeze_block
, ctdb
->ev
);
633 int32_t ctdb_control_thaw(struct ctdb_context
*ctdb
, bool check_recmode
)
635 if (check_recmode
&& ctdb
->recovery_mode
== CTDB_RECOVERY_ACTIVE
) {
636 DEBUG(DEBUG_ERR
, ("Failing to thaw databases while "
637 "recovery is active\n"));
641 DEBUG(DEBUG_ERR
,("Thawing all\n"));
643 /* cancel any pending transactions */
644 if (ctdb
->freeze_transaction_started
) {
645 ctdb_db_iterator(ctdb
, db_transaction_cancel_handler
, NULL
);
646 ctdb
->freeze_transaction_started
= false;
649 ctdb_db_iterator(ctdb
, db_thaw
, NULL
);
650 TALLOC_FREE(ctdb
->freeze_handle
);
652 ctdb_call_resend_all(ctdb
);
657 * Database transaction wrappers
659 * These functions are wrappers around transaction start/cancel/commit handlers.
662 struct db_start_transaction_state
{
663 uint32_t transaction_id
;
664 bool transaction_started
;
667 static int db_start_transaction(struct ctdb_db_context
*ctdb_db
,
670 struct db_start_transaction_state
*state
=
671 (struct db_start_transaction_state
*)private_data
;
673 bool transaction_started
;
675 if (ctdb_db
->freeze_mode
!= CTDB_FREEZE_FROZEN
) {
677 ("Database %s not frozen, cannot start transaction\n",
682 transaction_started
= state
->transaction_started
&
683 ctdb_db
->freeze_transaction_started
;
685 ret
= db_transaction_start_handler(ctdb_db
,
686 &transaction_started
);
691 ctdb_db
->freeze_transaction_started
= true;
692 ctdb_db
->freeze_transaction_id
= state
->transaction_id
;
697 static int db_cancel_transaction(struct ctdb_db_context
*ctdb_db
,
702 ret
= db_transaction_cancel_handler(ctdb_db
, private_data
);
707 ctdb_db
->freeze_transaction_started
= false;
712 struct db_commit_transaction_state
{
713 uint32_t transaction_id
;
714 unsigned int healthy_nodes
;
717 static int db_commit_transaction(struct ctdb_db_context
*ctdb_db
,
720 struct db_commit_transaction_state
*state
=
721 (struct db_commit_transaction_state
*)private_data
;
724 if (ctdb_db
->freeze_mode
!= CTDB_FREEZE_FROZEN
) {
726 ("Database %s not frozen, cannot commit transaction\n",
731 if (!ctdb_db
->freeze_transaction_started
) {
732 DEBUG(DEBUG_ERR
, ("Transaction not started on %s\n",
737 if (ctdb_db
->freeze_transaction_id
!= state
->transaction_id
) {
739 ("Incorrect transaction commit id 0x%08x for %s\n",
740 state
->transaction_id
, ctdb_db
->db_name
));
744 ret
= db_transaction_commit_handler(ctdb_db
, &state
->healthy_nodes
);
749 ctdb_db
->freeze_transaction_started
= false;
750 ctdb_db
->freeze_transaction_id
= 0;
751 ctdb_db
->generation
= state
->transaction_id
;
756 * Start a transaction on a database - used for db recovery
758 int32_t ctdb_control_db_transaction_start(struct ctdb_context
*ctdb
,
761 struct ctdb_transdb
*w
=
762 (struct ctdb_transdb
*)indata
.dptr
;
763 struct ctdb_db_context
*ctdb_db
;
764 struct db_start_transaction_state state
;
766 ctdb_db
= find_ctdb_db(ctdb
, w
->db_id
);
767 if (ctdb_db
== NULL
) {
769 ("Transaction start for unknown dbid 0x%08x\n",
774 state
.transaction_id
= w
->tid
;
775 state
.transaction_started
= true;
777 return db_start_transaction(ctdb_db
, &state
);
781 * Cancel a transaction on a database - used for db recovery
783 int32_t ctdb_control_db_transaction_cancel(struct ctdb_context
*ctdb
,
786 uint32_t db_id
= *(uint32_t *)indata
.dptr
;
787 struct ctdb_db_context
*ctdb_db
;
789 ctdb_db
= find_ctdb_db(ctdb
, db_id
);
790 if (ctdb_db
== NULL
) {
792 ("Transaction cancel for unknown dbid 0x%08x\n", db_id
));
796 DEBUG(DEBUG_ERR
, ("Recovery db transaction cancelled for %s\n",
799 return db_cancel_transaction(ctdb_db
, NULL
);
803 * Commit a transaction on a database - used for db recovery
805 int32_t ctdb_control_db_transaction_commit(struct ctdb_context
*ctdb
,
808 struct ctdb_transdb
*w
=
809 (struct ctdb_transdb
*)indata
.dptr
;
810 struct ctdb_db_context
*ctdb_db
;
811 struct db_commit_transaction_state state
;
812 unsigned int healthy_nodes
, i
;
814 ctdb_db
= find_ctdb_db(ctdb
, w
->db_id
);
815 if (ctdb_db
== NULL
) {
817 ("Transaction commit for unknown dbid 0x%08x\n",
823 for (i
=0; i
< ctdb
->num_nodes
; i
++) {
824 if (ctdb
->nodes
[i
]->flags
== 0) {
829 state
.transaction_id
= w
->tid
;
830 state
.healthy_nodes
= healthy_nodes
;
832 return db_commit_transaction(ctdb_db
, &state
);
836 wipe a database - only possible when in a frozen transaction
838 int32_t ctdb_control_wipe_database(struct ctdb_context
*ctdb
, TDB_DATA indata
)
840 struct ctdb_transdb w
= *(struct ctdb_transdb
*)indata
.dptr
;
841 struct ctdb_db_context
*ctdb_db
;
843 ctdb_db
= find_ctdb_db(ctdb
, w
.db_id
);
845 DEBUG(DEBUG_ERR
,(__location__
" Unknown db 0x%x\n", w
.db_id
));
849 if (ctdb_db
->freeze_mode
!= CTDB_FREEZE_FROZEN
) {
850 DEBUG(DEBUG_ERR
,(__location__
" Failed transaction_start while not frozen\n"));
854 if (!ctdb_db
->freeze_transaction_started
) {
855 DEBUG(DEBUG_ERR
,(__location__
" transaction not started\n"));
859 if (w
.tid
!= ctdb_db
->freeze_transaction_id
) {
860 DEBUG(DEBUG_ERR
,(__location__
" incorrect transaction id 0x%x in commit\n", w
.tid
));
864 if (tdb_wipe_all(ctdb_db
->ltdb
->tdb
) != 0) {
865 DEBUG(DEBUG_ERR
,(__location__
" Failed to wipe database for db '%s'\n",
870 if (ctdb_db_volatile(ctdb_db
)) {
871 talloc_free(ctdb_db
->delete_queue
);
872 talloc_free(ctdb_db
->fetch_queue
);
873 ctdb_db
->delete_queue
= trbt_create(ctdb_db
, 0);
874 if (ctdb_db
->delete_queue
== NULL
) {
875 DEBUG(DEBUG_ERR
, (__location__
" Failed to re-create "
876 "the delete queue.\n"));
879 ctdb_db
->fetch_queue
= trbt_create(ctdb_db
, 0);
880 if (ctdb_db
->fetch_queue
== NULL
) {
881 DEBUG(DEBUG_ERR
, (__location__
" Failed to re-create "
882 "the fetch queue.\n"));
890 bool ctdb_db_frozen(struct ctdb_db_context
*ctdb_db
)
892 if (ctdb_db
->freeze_mode
!= CTDB_FREEZE_FROZEN
) {
899 bool ctdb_db_all_frozen(struct ctdb_context
*ctdb
)
901 if (ctdb
->freeze_mode
!= CTDB_FREEZE_FROZEN
) {
907 bool ctdb_db_allow_access(struct ctdb_db_context
*ctdb_db
)
909 if (ctdb_db
->freeze_mode
== CTDB_FREEZE_NONE
) {
910 /* If database is not frozen, then allow access. */
912 } else if (ctdb_db
->freeze_transaction_started
) {
913 /* If database is frozen, allow access only if the
914 * transaction is started. This is required during
917 * If a node is inactive, then transaction is not started.