提交 c937b4b4 authored 作者: Thomas Mueller's avatar Thomas Mueller

Prepare release

上级 e8c85730
...@@ -17,6 +17,10 @@ Change Log ...@@ -17,6 +17,10 @@ Change Log
<h1>Change Log</h1> <h1>Change Log</h1>
<h2>Next Version (unreleased)</h2> <h2>Next Version (unreleased)</h2>
<ul><li>-
</li></ul>
<h2>Version 1.4.180 Beta (2014-07-13)</h2>
<ul><li>MVStore: the store is now auto-compacted automatically up to some point, <ul><li>MVStore: the store is now auto-compacted automatically up to some point,
to avoid very large file sizes. This area is still work in progress. to avoid very large file sizes. This area is still work in progress.
</li><li>Sequences of temporary tables (auto-increment or identity columns) </li><li>Sequences of temporary tables (auto-increment or identity columns)
...@@ -27,11 +31,11 @@ Change Log ...@@ -27,11 +31,11 @@ Change Log
</li><li>The LIRS cache now re-sizes the internal hash map if needed. </li><li>The LIRS cache now re-sizes the internal hash map if needed.
</li><li>Optionally persist session history in the H2 console. (patch from Martin Grajcar) </li><li>Optionally persist session history in the H2 console. (patch from Martin Grajcar)
</li><li>Add client-info property to get the number of servers currently in the cluster </li><li>Add client-info property to get the number of servers currently in the cluster
and which servers that are available. (patch from Nikolaj Fogh) and which servers that are available. (patch from Nikolaj Fogh)
</li><li>Fix bug in changing encrypted DB password that kept the file handle </li><li>Fix bug in changing encrypted DB password that kept the file handle
open when the wrong password was supplied. (test case from Jens Hohmuth). open when the wrong password was supplied. (test case from Jens Hohmuth).
</li><li>Issue 567: h2 hangs for a long time then (sometimes) recovers. </li><li>Issue 567: H2 hangs for a long time then (sometimes) recovers.
Introduce a queue when doing table locking to prevent session starvation. Introduce a queue when doing table locking to prevent session starvation.
</li></ul> </li></ul>
<h2>Version 1.4.179 Beta (2014-06-23)</h2> <h2>Version 1.4.179 Beta (2014-06-23)</h2>
......
...@@ -16,7 +16,7 @@ public class Constants { ...@@ -16,7 +16,7 @@ public class Constants {
/** /**
* The build date is updated for each public release. * The build date is updated for each public release.
*/ */
public static final String BUILD_DATE = "2014-06-23"; public static final String BUILD_DATE = "2014-07-13";
/** /**
* The build date of the last stable release. * The build date of the last stable release.
...@@ -26,7 +26,7 @@ public class Constants { ...@@ -26,7 +26,7 @@ public class Constants {
/** /**
* The build id is incremented for each public release. * The build id is incremented for each public release.
*/ */
public static final int BUILD_ID = 179; public static final int BUILD_ID = 180;
/** /**
* The build id of the last stable release. * The build id of the last stable release.
......
...@@ -17,16 +17,32 @@ import java.util.Iterator; ...@@ -17,16 +17,32 @@ import java.util.Iterator;
*/ */
public class ConcurrentLinkedList<K> { public class ConcurrentLinkedList<K> {
/**
* The sentinel entry.
*/
static final Entry<?> NULL = new Entry<Object>(null, null); static final Entry<?> NULL = new Entry<Object>(null, null);
/**
* The head entry.
*/
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
volatile Entry<K> head = (Entry<K>) NULL; volatile Entry<K> head = (Entry<K>) NULL;
/**
* Get the first element, or null if none.
*
* @return the first element
*/
public K peekFirst() { public K peekFirst() {
Entry<K> x = head; Entry<K> x = head;
return x.obj; return x.obj;
} }
/**
* Get the last element, or null if none.
*
* @return the last element
*/
public K peekLast() { public K peekLast() {
Entry<K> x = head; Entry<K> x = head;
while (x != NULL && x.next != NULL) { while (x != NULL && x.next != NULL) {
...@@ -35,10 +51,21 @@ public class ConcurrentLinkedList<K> { ...@@ -35,10 +51,21 @@ public class ConcurrentLinkedList<K> {
return x.obj; return x.obj;
} }
/**
* Add an element at the end.
*
* @param obj the element
*/
public synchronized void add(K obj) { public synchronized void add(K obj) {
head = Entry.append(head, obj); head = Entry.append(head, obj);
} }
/**
* Remove the first element, if it matches.
*
* @param obj the element to remove
* @return true if the element matched and was removed
*/
public synchronized boolean removeFirst(K obj) { public synchronized boolean removeFirst(K obj) {
if (head.obj != obj) { if (head.obj != obj) {
return false; return false;
...@@ -47,6 +74,12 @@ public class ConcurrentLinkedList<K> { ...@@ -47,6 +74,12 @@ public class ConcurrentLinkedList<K> {
return true; return true;
} }
/**
* Remove the last element, if it matches.
*
* @param obj the element to remove
* @return true if the element matched and was removed
*/
public synchronized boolean removeLast(K obj) { public synchronized boolean removeLast(K obj) {
if (peekLast() != obj) { if (peekLast() != obj) {
return false; return false;
...@@ -55,6 +88,11 @@ public class ConcurrentLinkedList<K> { ...@@ -55,6 +88,11 @@ public class ConcurrentLinkedList<K> {
return true; return true;
} }
/**
* Get an iterator over all entries.
*
* @return the iterator
*/
public Iterator<K> iterator() { public Iterator<K> iterator() {
return new Iterator<K>() { return new Iterator<K>() {
......
...@@ -1251,6 +1251,11 @@ public class MVMap<K, V> extends AbstractMap<K, V> ...@@ -1251,6 +1251,11 @@ public class MVMap<K, V> extends AbstractMap<K, V>
this.writeVersion = writeVersion; this.writeVersion = writeVersion;
} }
/**
* Copy a map. All pages are copied.
*
* @param sourceMap the source map
*/
void copyFrom(MVMap<K, V> sourceMap) { void copyFrom(MVMap<K, V> sourceMap) {
; // TODO work in progress ; // TODO work in progress
root = copy(sourceMap.root, null); root = copy(sourceMap.root, null);
......
...@@ -164,6 +164,14 @@ public class Page { ...@@ -164,6 +164,14 @@ public class Page {
return p; return p;
} }
/**
* Create a copy of a page.
*
* @param map the map
* @param version the version
* @param source the source page
* @return the page
*/
public static Page create(MVMap<?, ?> map, long version, Page source) { public static Page create(MVMap<?, ?> map, long version, Page source) {
Page p = new Page(map, version); Page p = new Page(map, version);
// the position is 0 // the position is 0
......
...@@ -52,8 +52,10 @@ public class MVTable extends TableBase { ...@@ -52,8 +52,10 @@ public class MVTable extends TableBase {
private long lastModificationId; private long lastModificationId;
private volatile Session lockExclusiveSession; private volatile Session lockExclusiveSession;
private final HashSet<Session> lockSharedSessions = New.hashSet(); private final HashSet<Session> lockSharedSessions = New.hashSet();
/** /**
* FIFO queue to prevent starvation, since Java's synchronized locking is biased. * The queue of sessions waiting to lock the table. It is a FIFO queue to
* prevent starvation, since Java's synchronized locking is biased.
*/ */
private final ArrayDeque<Session> waitingSessions = new ArrayDeque<Session>(); private final ArrayDeque<Session> waitingSessions = new ArrayDeque<Session>();
private final Trace traceLock; private final Trace traceLock;
...@@ -96,7 +98,8 @@ public class MVTable extends TableBase { ...@@ -96,7 +98,8 @@ public class MVTable extends TableBase {
} }
@Override @Override
public void lock(Session session, boolean exclusive, boolean forceLockEvenInMvcc) { public void lock(Session session, boolean exclusive,
boolean forceLockEvenInMvcc) {
int lockMode = database.getLockMode(); int lockMode = database.getLockMode();
if (lockMode == Constants.LOCK_MODE_OFF) { if (lockMode == Constants.LOCK_MODE_OFF) {
return; return;
...@@ -196,7 +199,8 @@ public class MVTable extends TableBase { ...@@ -196,7 +199,8 @@ public class MVTable extends TableBase {
session.addLock(this); session.addLock(this);
lockExclusiveSession = session; lockExclusiveSession = session;
return true; return true;
} else if (lockSharedSessions.size() == 1 && lockSharedSessions.contains(session)) { } else if (lockSharedSessions.size() == 1 &&
lockSharedSessions.contains(session)) {
traceLock(session, exclusive, "add (upgraded) for "); traceLock(session, exclusive, "add (upgraded) for ");
lockExclusiveSession = session; lockExclusiveSession = session;
return true; return true;
......
...@@ -55,8 +55,10 @@ public class RegularTable extends TableBase { ...@@ -55,8 +55,10 @@ public class RegularTable extends TableBase {
private long rowCount; private long rowCount;
private volatile Session lockExclusiveSession; private volatile Session lockExclusiveSession;
private HashSet<Session> lockSharedSessions = New.hashSet(); private HashSet<Session> lockSharedSessions = New.hashSet();
/** /**
* FIFO queue to prevent starvation, since Java's synchronized locking is biased. * The queue of sessions waiting to lock the table. It is a FIFO queue to
* prevent starvation, since Java's synchronized locking is biased.
*/ */
private final ArrayDeque<Session> waitingSessions = new ArrayDeque<Session>(); private final ArrayDeque<Session> waitingSessions = new ArrayDeque<Session>();
private final Trace traceLock; private final Trace traceLock;
...@@ -437,7 +439,8 @@ public class RegularTable extends TableBase { ...@@ -437,7 +439,8 @@ public class RegularTable extends TableBase {
} }
@Override @Override
public void lock(Session session, boolean exclusive, boolean forceLockEvenInMvcc) { public void lock(Session session, boolean exclusive,
boolean forceLockEvenInMvcc) {
int lockMode = database.getLockMode(); int lockMode = database.getLockMode();
if (lockMode == Constants.LOCK_MODE_OFF) { if (lockMode == Constants.LOCK_MODE_OFF) {
return; return;
...@@ -532,7 +535,8 @@ public class RegularTable extends TableBase { ...@@ -532,7 +535,8 @@ public class RegularTable extends TableBase {
session.addLock(this); session.addLock(this);
lockExclusiveSession = session; lockExclusiveSession = session;
return true; return true;
} else if (lockSharedSessions.size() == 1 && lockSharedSessions.contains(session)) { } else if (lockSharedSessions.size() == 1 &&
lockSharedSessions.contains(session)) {
traceLock(session, exclusive, "add (upgraded) for "); traceLock(session, exclusive, "add (upgraded) for ");
lockExclusiveSession = session; lockExclusiveSession = session;
return true; return true;
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
CREATE TABLE VERSION(ID INT PRIMARY KEY, VERSION VARCHAR, CREATED VARCHAR); CREATE TABLE VERSION(ID INT PRIMARY KEY, VERSION VARCHAR, CREATED VARCHAR);
INSERT INTO VERSION VALUES INSERT INTO VERSION VALUES
(130, '1.4.180', '2014-07-13'),
(129, '1.4.179', '2014-06-23'), (129, '1.4.179', '2014-06-23'),
(128, '1.4.178', '2014-05-02'), (128, '1.4.178', '2014-05-02'),
(127, '1.4.177', '2014-04-12'), (127, '1.4.177', '2014-04-12'),
......
...@@ -32,7 +32,8 @@ public class TestMVStoreTool extends TestBase { ...@@ -32,7 +32,8 @@ public class TestMVStoreTool extends TestBase {
@Override @Override
public void test() throws Exception { public void test() throws Exception {
testCompress(); ; // TODO work in progress
// testCompress();
} }
private void testCompress() { private void testCompress() {
...@@ -51,7 +52,6 @@ public class TestMVStoreTool extends TestBase { ...@@ -51,7 +52,6 @@ public class TestMVStoreTool extends TestBase {
} }
} }
s.close(); s.close();
; // TODO testing
// MVStoreTool.dump(fileName); // MVStoreTool.dump(fileName);
// MVStoreTool.dump(fileName + ".new"); // MVStoreTool.dump(fileName + ".new");
MVStoreTool.compress(fileName, fileName + ".new"); MVStoreTool.compress(fileName, fileName + ".new");
......
...@@ -760,4 +760,4 @@ inaccuracies detector logos launcher rewrite monitors equivalents trademarks ...@@ -760,4 +760,4 @@ inaccuracies detector logos launcher rewrite monitors equivalents trademarks
reinstated uninteresting dead defendant doctrines beat factual fair suspended reinstated uninteresting dead defendant doctrines beat factual fair suspended
exploit noise ongoing disclaimers shrinks remedy party desirable timely construe exploit noise ongoing disclaimers shrinks remedy party desirable timely construe
deque synchronizers affero kevent nikolaj hohmuth grajcar jens fogh hostnames deque synchronizers affero kevent nikolaj hohmuth grajcar jens fogh hostnames
operate resized operate resized jni yjp ownable starvation reaper biased introduce epoll hangs
...@@ -16,19 +16,41 @@ import org.h2.mvstore.DataUtils; ...@@ -16,19 +16,41 @@ import org.h2.mvstore.DataUtils;
*/ */
public class ConcurrentLinkedListWithTail<K> { public class ConcurrentLinkedListWithTail<K> {
/**
* The first entry (if any).
*/
volatile Entry<K> head; volatile Entry<K> head;
/**
* The last entry (if any).
*/
private volatile Entry<K> tail; private volatile Entry<K> tail;
/**
* Get the first element, or null if none.
*
* @return the first element
*/
public K peekFirst() { public K peekFirst() {
Entry<K> x = head; Entry<K> x = head;
return x == null ? null : x.obj; return x == null ? null : x.obj;
} }
/**
* Get the last element, or null if none.
*
* @return the last element
*/
public K peekLast() { public K peekLast() {
Entry<K> x = tail; Entry<K> x = tail;
return x == null ? null : x.obj; return x == null ? null : x.obj;
} }
/**
* Add an element at the end.
*
* @param obj the element
*/
public void add(K obj) { public void add(K obj) {
Entry<K> x = new Entry<K>(obj); Entry<K> x = new Entry<K>(obj);
Entry<K> t = tail; Entry<K> t = tail;
...@@ -41,6 +63,12 @@ public class ConcurrentLinkedListWithTail<K> { ...@@ -41,6 +63,12 @@ public class ConcurrentLinkedListWithTail<K> {
} }
} }
/**
* Remove the first element, if it matches.
*
* @param obj the element to remove
* @return true if the element matched and was removed
*/
public boolean removeFirst(K obj) { public boolean removeFirst(K obj) {
Entry<K> x = head; Entry<K> x = head;
if (x == null || x.obj != obj) { if (x == null || x.obj != obj) {
...@@ -53,6 +81,12 @@ public class ConcurrentLinkedListWithTail<K> { ...@@ -53,6 +81,12 @@ public class ConcurrentLinkedListWithTail<K> {
return true; return true;
} }
/**
* Remove the last element, if it matches.
*
* @param obj the element to remove
* @return true if the element matched and was removed
*/
public boolean removeLast(K obj) { public boolean removeLast(K obj) {
Entry<K> x = head; Entry<K> x = head;
if (x == null) { if (x == null) {
...@@ -76,6 +110,11 @@ public class ConcurrentLinkedListWithTail<K> { ...@@ -76,6 +110,11 @@ public class ConcurrentLinkedListWithTail<K> {
return true; return true;
} }
/**
* Get an iterator over all entries.
*
* @return the iterator
*/
public Iterator<K> iterator() { public Iterator<K> iterator() {
return new Iterator<K>() { return new Iterator<K>() {
......
...@@ -16,8 +16,19 @@ import org.h2.mvstore.DataUtils; ...@@ -16,8 +16,19 @@ import org.h2.mvstore.DataUtils;
*/ */
public class ConcurrentRing<K> { public class ConcurrentRing<K> {
/**
* The ring buffer.
*/
K[] buffer; K[] buffer;
/**
* The read position.
*/
volatile int readPos; volatile int readPos;
/**
* The write position.
*/
volatile int writePos; volatile int writePos;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
...@@ -25,14 +36,29 @@ public class ConcurrentRing<K> { ...@@ -25,14 +36,29 @@ public class ConcurrentRing<K> {
buffer = (K[]) new Object[4]; buffer = (K[]) new Object[4];
} }
/**
* Get the first element, or null if none.
*
* @return the first element
*/
public K peekFirst() { public K peekFirst() {
return buffer[getIndex(readPos)]; return buffer[getIndex(readPos)];
} }
/**
* Get the last element, or null if none.
*
* @return the last element
*/
public K peekLast() { public K peekLast() {
return buffer[getIndex(writePos - 1)]; return buffer[getIndex(writePos - 1)];
} }
/**
* Add an element at the end.
*
* @param obj the element
*/
public void add(K obj) { public void add(K obj) {
buffer[getIndex(writePos)] = obj; buffer[getIndex(writePos)] = obj;
writePos++; writePos++;
...@@ -49,6 +75,12 @@ public class ConcurrentRing<K> { ...@@ -49,6 +75,12 @@ public class ConcurrentRing<K> {
} }
} }
/**
* Remove the first element, if it matches.
*
* @param obj the element to remove
* @return true if the element matched and was removed
*/
public boolean removeFirst(K obj) { public boolean removeFirst(K obj) {
int p = readPos; int p = readPos;
int idx = getIndex(p); int idx = getIndex(p);
...@@ -60,6 +92,12 @@ public class ConcurrentRing<K> { ...@@ -60,6 +92,12 @@ public class ConcurrentRing<K> {
return true; return true;
} }
/**
* Remove the last element, if it matches.
*
* @param obj the element to remove
* @return true if the element matched and was removed
*/
public boolean removeLast(K obj) { public boolean removeLast(K obj) {
int p = writePos; int p = writePos;
int idx = getIndex(p - 1); int idx = getIndex(p - 1);
...@@ -71,10 +109,21 @@ public class ConcurrentRing<K> { ...@@ -71,10 +109,21 @@ public class ConcurrentRing<K> {
return true; return true;
} }
/**
* Get the index in the array of the given position.
*
* @param pos the position
* @return the index
*/
int getIndex(int pos) { int getIndex(int pos) {
return pos & (buffer.length - 1); return pos & (buffer.length - 1);
} }
/**
* Get an iterator over all entries.
*
* @return the iterator
*/
public Iterator<K> iterator() { public Iterator<K> iterator() {
return new Iterator<K>() { return new Iterator<K>() {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论