Skip to content

Commit

Permalink
MDEV-30863 Server freeze, all threads in trx_assign_rseg_low()
Browse files Browse the repository at this point in the history
trx_assign_rseg_low(): Simplify the debug check.

trx_rseg_t::reinit(): Reset the skip_allocation() flag.
This logic was broken in the merge
commit 3e2ad0e
of commit 0de3be8
(that is, innodb_undo_log_truncate=ON would never be "completed").

Tested by: Matthias Leich
  • Loading branch information
dr-m committed Apr 18, 2023
1 parent c28d1a6 commit 485a1b1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
3 changes: 2 additions & 1 deletion storage/innobase/include/trx0rseg.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ struct alignas(CPU_LEVEL1_DCACHE_LINESIZE) trx_rseg_t
#endif
}
/** @return whether the segment is marked for undo truncation */
bool skip_allocation() const { return ref_load() & SKIP; }
bool skip_allocation() const
{ return ref.load(std::memory_order_acquire) & SKIP; }
/** Increment the reference count */
void acquire()
{ ut_d(auto r=) ref.fetch_add(REF); ut_ad(!(r & SKIP)); }
Expand Down
1 change: 1 addition & 0 deletions storage/innobase/trx/trx0rseg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ void trx_rseg_t::reinit(uint32_t page)
last_commit_and_offset= 0;
last_page_no= FIL_NULL;
curr_size= 1;
ref.store(0, std::memory_order_release);
}

/** Read the undo log lists.
Expand Down
20 changes: 5 additions & 15 deletions storage/innobase/trx/trx0trx.cc
Original file line number Diff line number Diff line change
Expand Up @@ -811,30 +811,20 @@ static void trx_assign_rseg_low(trx_t *trx)
static Atomic_counter<unsigned> rseg_slot;
unsigned slot = rseg_slot++ % TRX_SYS_N_RSEGS;
ut_d(if (trx_rseg_n_slots_debug) slot = 0);
ut_d(const auto start_scan_slot = slot);
trx_rseg_t* rseg;

#ifdef UNIV_DEBUG
ulint start_scan_slot = slot;
bool look_for_rollover = false;
#endif /* UNIV_DEBUG */

bool allocated;

do {
for (;;) {
rseg = &trx_sys.rseg_array[slot];

#ifdef UNIV_DEBUG
/* Ensure that we are not revisiting the same
slot that we have already inspected. */
if (look_for_rollover) {
do {
ut_d(if (!trx_rseg_n_slots_debug) continue);
slot = (slot + 1) % TRX_SYS_N_RSEGS;
ut_ad(start_scan_slot != slot);
}
look_for_rollover = true;
#endif /* UNIV_DEBUG */

ut_d(if (!trx_rseg_n_slots_debug))
slot = (slot + 1) % TRX_SYS_N_RSEGS;
} while (0);

if (!rseg->space) {
continue;
Expand Down

3 comments on commit 485a1b1

@celestinoxp
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand c++ so this question might be weird. Shouldn't the files that are here have the formatted code? I mean in some places it has big spaces between words, in other places it has small spaces and in some places it has line breaks when some words should be on the same line. Does this make sense to you?

image

@grooverdan
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand c++ so this question might be weird. Shouldn't the files that are here have the formatted code? I mean in some places it has big spaces between words, in other places it has small spaces and in some places it has line breaks when some words should be on the same line. Does this make sense to you?

image

There's a mix of coding standards in place. Big spaces where the old standard, but the move is towards 2 space indent standard when new functions are added or substantially rewritten.

The line breaks are there to keep to a 80 column limit.

Function names are put in a separate line to their return type here too. With complex return types it can be hard to see the function name.

@dr-m
Copy link
Contributor Author

@dr-m dr-m commented on 485a1b1 Apr 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

InnoDB source code formatting was discussed in 2018. @montywi was of the opinion that we should not reformat all code, like mysql/mysql-server@ac7ad83 or mysql/mysql-server@cdf36f4 and several changes in between, because it could make it harder to contribute some code from forked code bases.

Another problem with automatic reformatting is that some parts of the formatting rules (CODING_STANDARDS.md cannot be expressed in .clang-format).

Please sign in to comment.