@@ -61,108 +61,83 @@ static void fin_body([[maybe_unused]] bool force_shut_down_logging) try {
6161 // set flag
6262 set_is_shutdowning (true );
6363
64- if (get_used_database_options ().get_open_mode () !=
65- database_options::open_mode::MAINTENANCE) {
66-
67- /* *
68- * about back ground worker about commit
69- * background worker about commit may access global data (object), so it
70- * must execute before cleanup environment.
71- */
72- VLOG (log_debug_timing_event) << log_location_prefix_timing_event
73- << " shutdown:start_bg_commit" ;
74- bg_work::bg_commit::fin ();
75- VLOG (log_debug_timing_event)
76- << log_location_prefix_timing_event << " shutdown:end_bg_commit" ;
77-
78- // about datastore
64+ /* *
65+ * about back ground worker about commit
66+ * background worker about commit may access global data (object), so it
67+ * must execute before cleanup environment.
68+ */
69+ VLOG (log_debug_timing_event) << log_location_prefix_timing_event << " shutdown:start_bg_commit" ;
70+ bg_work::bg_commit::fin ();
71+ VLOG (log_debug_timing_event) << log_location_prefix_timing_event << " shutdown:end_bg_commit" ;
72+
73+ // about datastore
7974#if defined(PWAL)
80- VLOG (log_debug_timing_event)
81- << log_location_prefix_timing_event
82- << " shutdown:start_send_txlog_wait_durable" ;
83- lpwal::fin (); // stop daemon
84- if (!force_shut_down_logging) {
85- // flush remaining log
86- lpwal::flush_remaining_log (); // (*1)
87- epoch::epoch_t ce{epoch::get_global_epoch ()};
88- // (*1)'s log must be before ce timing.
89- // wait durable above flushing
90- for (;;) {
91- if (epoch::get_datastore_durable_epoch () >= ce) { break ; }
92- _mm_pause ();
93- }
75+ VLOG (log_debug_timing_event) << log_location_prefix_timing_event << " shutdown:start_send_txlog_wait_durable" ;
76+ lpwal::fin (); // stop daemon
77+ if (!force_shut_down_logging) {
78+ // flush remaining log
79+ lpwal::flush_remaining_log (); // (*1)
80+ epoch::epoch_t ce{epoch::get_global_epoch ()};
81+ // (*1)'s log must be before ce timing.
82+ // wait durable above flushing
83+ for (;;) {
84+ if (epoch::get_datastore_durable_epoch () >= ce) { break ; }
85+ _mm_pause ();
9486 }
95- VLOG (log_debug_timing_event) << log_location_prefix_timing_event
96- << " shutdown:end_send_txlog_wait_durable" ;
87+ }
88+ VLOG (log_debug_timing_event) << log_location_prefix_timing_event << " shutdown:end_send_txlog_wait_durable" ;
9789
9890#endif
99- // about callbacks
100- clear_durability_callbacks ();
101-
102- // about tx engine
103- VLOG (log_debug_timing_event)
104- << log_location_prefix_timing_event << " shutdown:start_gc" ;
105- garbage::fin ();
106- VLOG (log_debug_timing_event)
107- << log_location_prefix_timing_event << " shutdown:end_gc" ;
108- epoch::fin ();
91+ // about callbacks
92+ clear_durability_callbacks ();
93+
94+ // about tx engine
95+ VLOG (log_debug_timing_event) << log_location_prefix_timing_event << " shutdown:start_gc" ;
96+ garbage::fin ();
97+ VLOG (log_debug_timing_event) << log_location_prefix_timing_event << " shutdown:end_gc" ;
98+ epoch::fin ();
10999#ifdef PWAL
110- VLOG (log_debug_timing_event) << log_location_prefix_timing_event
111- << " shutdown:start_shutdown_datastore" ;
112- datastore::get_datastore ()->remove_persistent_callback ();
113- datastore::get_datastore ()->shutdown ().wait (); // this should after epoch::fin();
114- datastore::release_datastore ();
115- VLOG (log_debug_timing_event) << log_location_prefix_timing_event
116- << " shutdown:end_shutdown_datastore" ;
117- // cleanup about limestone
118- if (datastore::get_own_datastore () && !lpwal::get_log_dir_pointed ()) {
119- // log dir was not pointed. So remove log dir
120- VLOG (log_debug_timing_event) << log_location_prefix_timing_event
121- << " shutdown:start_cleanup_logdir" ;
122- lpwal::remove_under_log_dir ();
123- VLOG (log_debug_timing_event) << log_location_prefix_timing_event
124- << " shutdown:end_cleanup_logdir" ;
125- }
126- lpwal::clean_up_metadata ();
100+ VLOG (log_debug_timing_event) << log_location_prefix_timing_event << " shutdown:start_shutdown_datastore" ;
101+ datastore::get_datastore ()->remove_persistent_callback ();
102+ datastore::get_datastore ()->shutdown ().wait (); // this should after epoch::fin();
103+ datastore::release_datastore ();
104+ VLOG (log_debug_timing_event) << log_location_prefix_timing_event << " shutdown:end_shutdown_datastore" ;
105+ // cleanup about limestone
106+ if (datastore::get_own_datastore () && !lpwal::get_log_dir_pointed ()) {
107+ // log dir was not pointed. So remove log dir
108+ VLOG (log_debug_timing_event) << log_location_prefix_timing_event << " shutdown:start_cleanup_logdir" ;
109+ lpwal::remove_under_log_dir ();
110+ VLOG (log_debug_timing_event) << log_location_prefix_timing_event << " shutdown:end_cleanup_logdir" ;
111+ }
112+ lpwal::clean_up_metadata ();
127113#endif
128- VLOG (log_debug_timing_event) << log_location_prefix_timing_event
129- << " shutdown:start_delete_all_records" ;
130- bool fast_shutdown = is_fast_shutdown ();
131- if (fast_shutdown) {
132- LOG (INFO) << log_location_prefix << " skipped delete_all_records" ;
133- } else {
134- delete_all_records (); // This should be before wp::fin();
135- }
136- VLOG (log_debug_timing_event) << log_location_prefix_timing_event
137- << " shutdown:end_delete_all_records" ;
138- wp::fin (); // note: this use yakushima.
139- storage::fin (); // note: this use yakushima. delete meta storage.
140-
141- // about index
142- VLOG (log_debug_timing_event) << log_location_prefix_timing_event
143- << " shutdown:start_shutdown_yakushima" ;
144- if (fast_shutdown) {
145- yakushima::storage::get_storages ()->store_root_ptr (nullptr );
146- LOG (INFO) << log_location_prefix << " skipping yakushima destroy" ;
147- }
148- yakushima::fin ();
149- VLOG (log_debug_timing_event) << log_location_prefix_timing_event
150- << " shutdown:end_shutdown_yakushima" ;
151-
152- // // about thread pool
153- // VLOG(log_debug_timing_event) << log_location_prefix_timing_event
154- // << "shutdown:start_shutdown_thread_pool";
155- // thread_pool::fin();
156- // VLOG(log_debug_timing_event) << log_location_prefix_timing_event
157- // << "shutdown:end_shutdown_thread_pool";
158-
159- // about read area
160- read_plan::fin ();
114+ VLOG (log_debug_timing_event) << log_location_prefix_timing_event << " shutdown:start_delete_all_records" ;
115+ bool fast_shutdown = is_fast_shutdown ();
116+ if (fast_shutdown) {
117+ LOG (INFO) << log_location_prefix << " skipped delete_all_records" ;
161118 } else {
162- #ifdef PWAL
163- datastore::release_datastore ();
164- #endif
119+ delete_all_records (); // This should be before wp::fin();
120+ }
121+ VLOG (log_debug_timing_event) << log_location_prefix_timing_event << " shutdown:end_delete_all_records" ;
122+ wp::fin (); // note: this use yakushima.
123+ storage::fin (); // note: this use yakushima. delete meta storage.
124+
125+ // about index
126+ VLOG (log_debug_timing_event) << log_location_prefix_timing_event << " shutdown:start_shutdown_yakushima" ;
127+ if (fast_shutdown) {
128+ yakushima::storage::get_storages ()->store_root_ptr (nullptr );
129+ LOG (INFO) << log_location_prefix << " skipping yakushima destroy" ;
165130 }
131+ yakushima::fin ();
132+ VLOG (log_debug_timing_event) << log_location_prefix_timing_event << " shutdown:end_shutdown_yakushima" ;
133+
134+ // // about thread pool
135+ // VLOG(log_debug_timing_event) << log_location_prefix_timing_event << "shutdown:start_shutdown_thread_pool";
136+ // thread_pool::fin();
137+ // VLOG(log_debug_timing_event) << log_location_prefix_timing_event << "shutdown:end_shutdown_thread_pool";
138+
139+ // about read area
140+ read_plan::fin ();
166141
167142 // set flag
168143 set_is_shutdowning (false );
@@ -175,8 +150,7 @@ static void fin_body([[maybe_unused]] bool force_shut_down_logging) try {
175150}
176151
177152void fin ([[maybe_unused]] bool force_shut_down_logging) {
178- shirakami_log_entry << " fin, force_shut_down_logging: "
179- << force_shut_down_logging;
153+ shirakami_log_entry << " fin, force_shut_down_logging: " << force_shut_down_logging;
180154 fin_body (force_shut_down_logging);
181155 shirakami_log_exit << " fin" ;
182156}
0 commit comments