HBASE-2589 TestHRegion.testWritesWhileScanning flaky on trunk

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@947707 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2010-05-24 16:36:08 +00:00
parent 46cb0e99ed
commit f8ca192f92
2 changed files with 27 additions and 8 deletions

View File

@ -353,6 +353,8 @@ Release 0.21.0 - Unreleased
HBASE-2519 StoreFileScanner.seek swallows IOEs (Todd Lipcon via Stack) HBASE-2519 StoreFileScanner.seek swallows IOEs (Todd Lipcon via Stack)
HBASE-2516 Ugly IOE when region is being closed; rather, should NSRE HBASE-2516 Ugly IOE when region is being closed; rather, should NSRE
(Daniel Ploeg via Stack) (Daniel Ploeg via Stack)
HBASE-2589 TestHRegion.testWritesWhileScanning flaky on trunk
(Todd Lipcon via Stack)
IMPROVEMENTS IMPROVEMENTS
HBASE-1760 Cleanup TODOs in HTable HBASE-1760 Cleanup TODOs in HTable

View File

@ -2134,6 +2134,8 @@ public class TestHRegion extends HBaseTestCase {
initHRegion(tableName, method, families); initHRegion(tableName, method, families);
PutThread putThread = new PutThread(numRows, families, qualifiers); PutThread putThread = new PutThread(numRows, families, qualifiers);
putThread.start(); putThread.start();
putThread.waitForFirstPut();
FlushThread flushThread = new FlushThread(); FlushThread flushThread = new FlushThread();
flushThread.start(); flushThread.start();
@ -2183,6 +2185,8 @@ public class TestHRegion extends HBaseTestCase {
protected class PutThread extends Thread { protected class PutThread extends Thread {
private volatile boolean done; private volatile boolean done;
private volatile int numPutsFinished = 0;
private Throwable error = null; private Throwable error = null;
private int numRows; private int numRows;
private byte[][] families; private byte[][] families;
@ -2195,6 +2199,17 @@ public class TestHRegion extends HBaseTestCase {
this.qualifiers = qualifiers; this.qualifiers = qualifiers;
} }
/**
* Block until this thread has put at least one row.
*/
public void waitForFirstPut() throws InterruptedException {
// wait until put thread actually puts some data
while (numPutsFinished == 0) {
checkNoError();
Thread.sleep(50);
}
}
public void done() { public void done() {
done = true; done = true;
synchronized (this) { synchronized (this) {
@ -2211,7 +2226,6 @@ public class TestHRegion extends HBaseTestCase {
@Override @Override
public void run() { public void run() {
done = false; done = false;
int val = 0;
while (!done) { while (!done) {
try { try {
for (int r = 0; r < numRows; r++) { for (int r = 0; r < numRows; r++) {
@ -2219,18 +2233,19 @@ public class TestHRegion extends HBaseTestCase {
Put put = new Put(row); Put put = new Put(row);
for (byte[] family : families) { for (byte[] family : families) {
for (byte[] qualifier : qualifiers) { for (byte[] qualifier : qualifiers) {
put.add(family, qualifier, (long) val, put.add(family, qualifier, (long) numPutsFinished,
Bytes.toBytes(val)); Bytes.toBytes(numPutsFinished));
} }
} }
// System.out.println("Putting of kvsetsize=" + put.size()); // System.out.println("Putting of kvsetsize=" + put.size());
region.put(put); region.put(put);
if (val > 0 && val % 47 == 0) { numPutsFinished++;
System.out.println("put iteration = " + val); if (numPutsFinished > 0 && numPutsFinished % 47 == 0) {
Delete delete = new Delete(row, (long)val-30, null); System.out.println("put iteration = " + numPutsFinished);
Delete delete = new Delete(row, (long)numPutsFinished-30, null);
region.delete(delete, null, true); region.delete(delete, null, true);
} }
val++; numPutsFinished++;
} }
} catch (IOException e) { } catch (IOException e) {
LOG.error("error while putting records", e); LOG.error("error while putting records", e);
@ -2274,6 +2289,8 @@ public class TestHRegion extends HBaseTestCase {
initHRegion(tableName, method, families); initHRegion(tableName, method, families);
PutThread putThread = new PutThread(numRows, families, qualifiers); PutThread putThread = new PutThread(numRows, families, qualifiers);
putThread.start(); putThread.start();
putThread.waitForFirstPut();
FlushThread flushThread = new FlushThread(); FlushThread flushThread = new FlushThread();
flushThread.start(); flushThread.start();