cinchapi / concourse

Distributed database warehouse for transactions, search and analytics across time.
http://concoursedb.com
Apache License 2.0
315 stars 235 forks source link

Wide write locks are not shared #490

Closed jtnelson closed 1 year ago

jtnelson commented 1 year ago

The Engine should acquire sharable locks on a record to allow concurrent writes to different keys. But the writes that are acquired are not actually "shared".

In EngineAtomicOperationTest.java

@Test
    public void testConcurrentWritesToDifferentKeysInSameRecord()
            throws InterruptedException {
        int numThread = 50;
        long record = 1;
        AtomicInteger failed = new AtomicInteger(0);
        CountUpLatch latch = new CountUpLatch();
        for (int i = 0; i < numThread; ++i) {
            Thread thread = new Thread(() -> {
                AtomicOperation atomic = getStore(destination);
                atomic.add(Long.toString(Time.now()), TestData.getTObject(),
                        record);
                if(!atomic.commit()) {
                    failed.incrementAndGet();
                }
                latch.countUp();
            });
            thread.start();
        }
        latch.await(numThread);
        Assert.assertEquals(0, failed.get());
    }