Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugcheck 258 (page slot not empty) could occurs under high concurrent load [CORE2340] #2764

Closed
firebird-automations opened this issue Feb 24, 2009 · 6 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: @hvlad

When some relation is extended by the few attachments simultaneously bugcheck could occurs.
Reproduced with SS but it is independent on engine architecture.
Test executed 20 threads insering data in the same table. Bugcheck happens after few hours of work, so it is rare and hard to reproduce.

Commits: 0888aa8 ff50ab2

@firebird-automations
Copy link
Collaborator Author

Modified by: @hvlad

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

Fix Version: 2.5 Beta 1 [ 10251 ]

assignee: Vlad Khorsun [ hvlad ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @hvlad

A little explanation of bug and fix. Look at dpm.epp\extend_relation.
To link newly allocated data page into relation we need to find a free slot on some pointer page.
If there is no free slots we allocate and link new pointer page.

for \(pp\_sequence = relPages\-\>rel\_slot\_space;; pp\_sequence\+\+\) \{
	if \(\!\(ppage = get\_pointer\_page\(tdbb, relation, relPages, &pp\_window,
									pp\_sequence, LCK\_write\)\)\)
	\{
		BUGCHECK\(253\);	/\* msg 253 pointer page vanished from extend\_relation \*/
	\}
	SLONG\* slots = ppage\-\>ppg\_page;

...
if (ppage->ppg_header.pag_flags & ppg_eof) {

-- here we allocate new PP
ppage = (pointer_page*) DPM_allocate(tdbb, &new_pp_window);
ppage->ppg_header.pag_type = pag_pointer;
ppage->ppg_header.pag_flags |= ppg_eof;
ppage->ppg_relation = relation->rel_id;
ppage->ppg_sequence = ++pp_sequence;
slot = 0;
CCH_must_write(&new_pp_window);
CCH_RELEASE(tdbb, &new_pp_window);

-- here we store new PP number at in-memory array of PPs
vcl* vector = relPages->rel_pages =
vcl::newVector(*dbb->dbb_permanent, relPages->rel_pages, pp_sequence + 1);
(*vector)[pp_sequence] = new_pp_window.win_page.getPageNum();
-- after this point concurrent attachments in the same SS process could see new PP
-- but we didn't release sheduler still so they can't

		// hvlad: temporary tables don't save their pointer pages in RDB$PAGES
		if \(relation\-\>rel\_id && \(relPages\-\>rel\_instance\_id == 0\)\)
		\{

-- here we store new PP number in RDB$PAGES
DPM_pages(tdbb, relation->rel_id, pag_pointer,
(SLONG) pp_sequence, new_pp_window.win_page.getPageNum());
-- after this point any concurrent attachments could see new PP
-- and we of course released sheduler inside DPM_pages
}
relPages->rel_slot_space = pp_sequence;

		ppage = \(pointer\_page\*\) pp\_window\.win\_buffer;
		CCH\_MARK\(tdbb, &pp\_window\);
		ppage\-\>ppg\_header\.pag\_flags &= \~ppg\_eof;
		ppage\-\>ppg\_next = new\_pp\_window\.win\_page\.getPageNum\(\);

-- BUG : at this point slot 0 could be filled by some other attachment

- ppage = (pointer_page*) CCH_HANDOFF(tdbb, &pp_window, new_pp_window.win_page.getPageNum(),
- LCK_write, pag_pointer);
- break;

-- FIX : therefore release PP and go to the loop again, searching for free slot
+ --pp_sequence;
}
CCH_RELEASE(tdbb, &pp_window);
}

/* We've found a slot. Stick in the pointer to the data page */

if \(ppage\-\>ppg\_page\[slot\]\) 
\{

-- another BUG : pointer page was not released so engine is in bad shape and can't report error correclty
+ CCH_RELEASE(tdbb, &pp_window);
CORRUPT(258); /* msg 258 page slot not empty */
}

@firebird-automations
Copy link
Collaborator Author

Commented by: @hvlad

Fix is backported into 2.1.3

@firebird-automations
Copy link
Collaborator Author

Modified by: @hvlad

Fix Version: 2.1.3 [ 10302 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

status: Resolved [ 5 ] => Closed [ 6 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

QA Status: No test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment