summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAndreas Baumann <Andreas.Baumann@eurospider.com>2010-09-06 14:37:33 +0200
committerAndreas Baumann <Andreas.Baumann@eurospider.com>2010-09-06 14:37:33 +0200
commit23979669900d75bccefb5b4a825882d329a2bd9d (patch)
treea8e9f2d14608e87569d902219a48970654eb9600 /tests
parent1dcc640c490a6619eeba19a6bdb93c4ac8d5a6fc (diff)
downloadsqlitexx-23979669900d75bccefb5b4a825882d329a2bd9d.tar.gz
sqlitexx-23979669900d75bccefb5b4a825882d329a2bd9d.tar.bz2
some more places are handling SQLITE_BUSY correctly now, test9
still breaks under heavy load
Diffstat (limited to 'tests')
-rw-r--r--tests/test9.cpp38
1 files changed, 24 insertions, 14 deletions
diff --git a/tests/test9.cpp b/tests/test9.cpp
index cf61508..5252524 100644
--- a/tests/test9.cpp
+++ b/tests/test9.cpp
@@ -33,8 +33,8 @@
using namespace sqlite3xx;
using namespace std;
-const int NOF_PRODUCERS = 1;
-const int NOF_CONSUMERS = 1;
+const int NOF_PRODUCERS = 10;
+const int NOF_CONSUMERS = 10;
const int NOF_PRODUCER_TRANSACTIONS = 100;
const int NOF_PRODUCER_OPS = 100;
const int NOF_CONSUMER_TRANSACTIONS = 100;
@@ -64,8 +64,13 @@ static THREAD_FUNC_DECL produce( void *thread_data )
MUTEX_UNLOCK( cout_mutex );
}
for( int j = 0; j < NOF_PRODUCER_OPS; j++ ) {
- result r = t.prepared( "ins" )( no * 100000 + i * 1000 + j ).exec( );
- assert( r.affected_rows( ) == 1 );
+PRODUCER_INS_AGAIN:
+ try {
+ result r = t.prepared( "ins" )( no * 100000 + i * 1000 + j ).exec( );
+ assert( r.affected_rows( ) == 1 );
+ } catch( database_locked& e ) {
+ goto PRODUCER_INS_AGAIN;
+ }
}
t.commit( );
if( verbose ) {
@@ -98,16 +103,21 @@ static THREAD_FUNC_DECL consume( void *thread_data )
MUTEX_UNLOCK( cout_mutex );
}
for( int j = 0; j < NOF_CONSUMER_OPS; j++ ) {
- result r = t.prepared( "sel" ).exec( );
- int nof_rows = 1;
- for( result::const_iterator it = r.begin( ); it < r.end( ); it++, nof_rows++ ) {
- int x;
- it["x"].to( x );
- }
- if( verbose ) {
- MUTEX_LOCK( cout_mutex );
- cout << "consumer " << no << " transaction " << i << " got " << nof_rows << " rows." << endl;
- MUTEX_UNLOCK( cout_mutex );
+CONSUMER_SELECT_AGAIN:
+ try {
+ result r = t.prepared( "sel" ).exec( );
+ int nof_rows = 1;
+ for( result::const_iterator it = r.begin( ); it < r.end( ); it++, nof_rows++ ) {
+ int x;
+ it["x"].to( x );
+ }
+ if( verbose ) {
+ MUTEX_LOCK( cout_mutex );
+ cout << "consumer " << no << " transaction " << i << " got " << nof_rows << " rows." << endl;
+ MUTEX_UNLOCK( cout_mutex );
+ }
+ } catch( database_locked& e ) {
+ goto CONSUMER_SELECT_AGAIN;
}
}
t.commit( );