Exemple #1
0
/*
 * @- TMcommit
 * global commit without any multi-threaded access assumptions, thus
 * taking all BBP locks.  It creates a new database checkpoint.
 */
gdk_return
TMcommit(void)
{
	gdk_return ret = GDK_FAIL;

	/* commit with the BBP globally locked */
	BBPlock();
	if (prelude(getBBPsize(), NULL) == GDK_SUCCEED &&
	    BBPsync(getBBPsize(), NULL) == GDK_SUCCEED) {
		epilogue(getBBPsize(), NULL);
		ret = GDK_SUCCEED;
	}
	BBPunlock();
	return ret;
}
Exemple #2
0
/*
 * @- TMsubcommit
 *
 * Create a new checkpoint that is equal to the previous, with the
 * exception that for the passed list of batnames, the current state
 * will be reflected in the new checkpoint.
 *
 * On the bats in this list we assume exclusive access during the
 * operation.
 *
 * This operation is useful for e.g. adding a new XQuery document or
 * SQL table to the committed state (after bulk-load). Or for dropping
 * a table or doc, without forcing the total database to be clean,
 * which may require a lot of I/O.
 *
 * We expect the globally locked phase (BBPsync) to take little time
 * (<100ms) as only the BBP.dir is written out; and for the existing
 * bats that were modified, only some heap moves are done (moved from
 * BAKDIR to SUBDIR).  The atomic commit for sub-commit is the rename
 * of SUBDIR to DELDIR.
 *
 * As it does not take the BBP-locks (thanks to the assumption that
 * access is exclusive), the concurrency impact of subcommit is also
 * much lighter to ongoing concurrent query and update facilities than
 * a real global TMcommit.
 */
gdk_return
TMsubcommit_list(bat *subcommit, int cnt)
{
	int xx;
	gdk_return ret = GDK_FAIL;

	assert(cnt > 0);
	assert(subcommit[0] == 0); /* BBP artifact: slot 0 in the array will be ignored */

	/* sort the list on BAT id */
	GDKqsort(subcommit + 1, NULL, NULL, cnt - 1, sizeof(bat), 0, TYPE_bat);

	assert(cnt == 1 || subcommit[1] > 0);  /* all values > 0 */
	/* de-duplication of BAT ids in subcommit list
	 * this is needed because of legacy reasons (database
	 * upgrade) */
	for (xx = 2; xx < cnt; xx++) {
		if (subcommit[xx-1] == subcommit[xx]) {
			int i;
			cnt--;
			for (i = xx; i < cnt; i++)
				subcommit[i] = subcommit[i+1];
		}
	}
	if (prelude(cnt, subcommit) == GDK_SUCCEED) {	/* save the new bats outside the lock */
		/* lock just prevents BBPtrims, and other global
		 * (sub-)commits */
		for (xx = 0; xx <= BBP_THREADMASK; xx++)
			MT_lock_set(&GDKtrimLock(xx));
		if (BBPsync(cnt, subcommit) == GDK_SUCCEED) { /* write BBP.dir (++) */
			epilogue(cnt, subcommit);
			ret = GDK_SUCCEED;
		}
		for (xx = BBP_THREADMASK; xx >= 0; xx--)
			MT_lock_unset(&GDKtrimLock(xx));
	}
	return ret;
}
Exemple #3
0
str
TRNglobal_sync(bit *ret)
{
	*ret = BBPsync(getBBPsize(),NULL)?FALSE:TRUE;
	return MAL_SUCCEED;
}
Exemple #4
0
str
TRNglobal_sync(bit *ret)
{
	*ret = BBPsync(getBBPsize(), NULL) == GDK_SUCCEED;
	return MAL_SUCCEED;
}