[Xapian-discuss] Threaded test (in C++) to reproduce our
database problems
Eric B. Ridge
ebr@tcdi.com
Thu, 17 Jun 2004 00:30:50 -0400
> This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
--B_3170277052_25820478
Content-type: text/plain;
charset="US-ASCII"
Content-transfer-encoding: 7bit
>> Writer: ERROR=Db block overwritten
>
> But the writer thread shouldn't get this unless there's another writer.
Did you mean "writer to the same database" or "writer to ANY database"???
I've hacked up the C++ thread test to do this:
- 2 Writer threads. Each to a *different* database
- ZERO! reader threads.
In theory, these guys should not interfere with each other, right? Or am I
clueless here too?
Check this out:
----------------------------
$ rm -rf /tmp/*.db && build/xapian_threads
Opening /tmp/one.db
Opening /tmp/two.db
Writer /tmp/one.db: flush()
Writer /tmp/two.db: flush()
<repeats a bunch of times>
Writer /tmp/one.db: flush()
Writer /tmp/two.db: flush()
Writer /tmp/one.db: flush()
Writer /tmp/two.db: ERROR=Db block overwritten
Writer /tmp/two.db thread unexpectedly exited...
Writer /tmp/one.db: ERROR=Error reading block 44: got end of file
Writer /tmp/one.db thread unexpectedly exited...
-----------------------------
Explain this one. ;) Now I'm really stumped. Can't write to two separate
databases at a time? Hmm...
eric
--B_3170277052_25820478
Content-type: application/octet-stream; name="xapian_threads.cpp"
Content-disposition: attachment;
filename="xapian_threads.cpp"
Content-transfer-encoding: base64
I2luY2x1ZGUgPHhhcGlhbi5oPgojaW5jbHVkZSA8cHRocmVhZC5oPgojaW5jbHVkZSA8dW5p
c3RkLmg+CiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgInhhcGlhbl90aHJlYWRzLmgi
Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKcHRocmVhZF90IF93cml0ZXIxLCBfd3JpdGVyMjsK
CnZvaWQgZG9fd3JpdGVzKGNoYXIgKmRicGF0aCkgewoJY291dCA8PCAiT3BlbmluZyAiIDw8
IGRicGF0aCA8PCBlbmRsOwoJWGFwaWFuOjpXcml0YWJsZURhdGF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