Search in sources :

Example 6 with FilesFacadeImpl

use of io.questdb.std.FilesFacadeImpl in project questdb by bluestreak01.

the class O3FailureTest method testColumnTopLastDataOOODataFailRetryMapRoContended.

@Test
public void testColumnTopLastDataOOODataFailRetryMapRoContended() throws Exception {
    counter.set(1);
    executeWithPool(0, (compiler, sqlExecutionContext, sqlExecutionContext2) -> testColumnTopLastDataOOODataFailRetry0(sqlExecutionContext, sqlExecutionContext2), new FilesFacadeImpl() {

        long theFd = 0;

        @Override
        public long mmap(long fd, long len, long offset, int flags, int memoryTag) {
            if (fd == theFd && flags == Files.MAP_RO) {
                theFd = 0;
                return -1;
            }
            return super.mmap(fd, len, offset, flags, memoryTag);
        }

        @Override
        public long openRW(LPSZ name) {
            long fd = super.openRW(name);
            if (Chars.endsWith(name, "1970-01-07" + Files.SEPARATOR + "v11.d") && counter.decrementAndGet() == 0) {
                theFd = fd;
            }
            return fd;
        }
    });
}
Also used : LPSZ(io.questdb.std.str.LPSZ) FilesFacadeImpl(io.questdb.std.FilesFacadeImpl) Test(org.junit.Test)

Example 7 with FilesFacadeImpl

use of io.questdb.std.FilesFacadeImpl in project questdb by bluestreak01.

the class O3FailureTest method testColumnTopMidDataMergeDataFailRetryReadTopContended.

@Test
public void testColumnTopMidDataMergeDataFailRetryReadTopContended() throws Exception {
    counter.set(2);
    executeWithPool(0, (compiler, sqlExecutionContext, sqlExecutionContext2) -> testColumnTopMidDataMergeDataFailRetry0(sqlExecutionContext, sqlExecutionContext2), new FilesFacadeImpl() {

        long theFd;

        @Override
        public long openRO(LPSZ name) {
            long fd = super.openRO(name);
            if (Chars.endsWith(name, "1970-01-07" + Files.SEPARATOR + "v2.top") && counter.decrementAndGet() == 0) {
                theFd = fd;
            }
            return fd;
        }

        @Override
        public long read(long fd, long address, long len, long offset) {
            if (fd == theFd) {
                theFd = 0;
                return 5;
            }
            return super.read(fd, address, len, offset);
        }
    });
}
Also used : LPSZ(io.questdb.std.str.LPSZ) FilesFacadeImpl(io.questdb.std.FilesFacadeImpl) Test(org.junit.Test)

Example 8 with FilesFacadeImpl

use of io.questdb.std.FilesFacadeImpl in project questdb by bluestreak01.

the class O3FailureTest method testColumnTopMidMergeBlankFailRetryMergeFixMapRW.

@Test
public void testColumnTopMidMergeBlankFailRetryMergeFixMapRW() throws Exception {
    counter.set(1);
    executeWithoutPool(O3FailureTest::testColumnTopMidMergeBlankColumnFailRetry0, new FilesFacadeImpl() {

        long theFd = 0;

        @Override
        public long mmap(long fd, long len, long offset, int flags, int memoryTag) {
            if (fd != theFd) {
                return super.mmap(fd, len, offset, flags, memoryTag);
            }
            theFd = 0;
            return -1;
        }

        @Override
        public long openRW(LPSZ name) {
            long fd = super.openRW(name);
            if (Chars.endsWith(name, "1970-01-06.14" + Files.SEPARATOR + "v8.d") && counter.decrementAndGet() == 0) {
                theFd = fd;
            }
            return fd;
        }
    });
}
Also used : LPSZ(io.questdb.std.str.LPSZ) FilesFacadeImpl(io.questdb.std.FilesFacadeImpl) Test(org.junit.Test)

Example 9 with FilesFacadeImpl

use of io.questdb.std.FilesFacadeImpl in project questdb by bluestreak01.

the class O3FailureTest method testOutOfFileHandles.

@Test
public void testOutOfFileHandles() throws Exception {
    counter.set(1536);
    executeWithPool(4, O3FailureTest::testOutOfFileHandles0, new FilesFacadeImpl() {

        @Override
        public boolean close(long fd) {
            counter.incrementAndGet();
            return super.close(fd);
        }

        @Override
        public long openAppend(LPSZ name) {
            if (counter.decrementAndGet() < 0) {
                return -1;
            }
            return super.openAppend(name);
        }

        @Override
        public long openRO(LPSZ name) {
            if (counter.decrementAndGet() < 0) {
                return -1;
            }
            return super.openRO(name);
        }

        @Override
        public long openRW(LPSZ name) {
            if (counter.decrementAndGet() < 0) {
                return -1;
            }
            return super.openRW(name);
        }
    });
}
Also used : LPSZ(io.questdb.std.str.LPSZ) FilesFacadeImpl(io.questdb.std.FilesFacadeImpl) Test(org.junit.Test)

Example 10 with FilesFacadeImpl

use of io.questdb.std.FilesFacadeImpl in project questdb by bluestreak01.

the class SqlCodeGeneratorTest method testLatestByIOFailure.

@Test
public void testLatestByIOFailure() throws Exception {
    assertMemoryLeak(() -> {
        FilesFacade ff = new FilesFacadeImpl() {

            @Override
            public long openRO(LPSZ name) {
                if (Chars.endsWith(name, "b.d")) {
                    return -1;
                }
                return super.openRO(name);
            }
        };
        CairoConfiguration configuration = new DefaultCairoConfiguration(root) {

            @Override
            public FilesFacade getFilesFacade() {
                return ff;
            }
        };
        try (CairoEngine engine = new CairoEngine(configuration);
            SqlCompiler compiler = new SqlCompiler(engine)) {
            try {
                compiler.compile(("create table x as " + "(" + "select rnd_double(0)*100 a, rnd_symbol(5,4,4,1) b, timestamp_sequence(0, 100000000000) k from" + " long_sequence(200)" + ") timestamp(k) partition by DAY"), sqlExecutionContext);
                try (final RecordCursorFactory factory = compiler.compile("select * from x latest by b where b = 'PEHN' and a < 22", sqlExecutionContext).getRecordCursorFactory()) {
                    try {
                        assertCursor("a\tb\tk\n" + "5.942010834028\tPEHN\t1970-08-03T02:53:20.000000Z\n", factory, true, true, false);
                        Assert.fail();
                    } catch (CairoException e) {
                        TestUtils.assertContains(e.getFlyweightMessage(), "could not open");
                    }
                }
                Assert.assertEquals(0, engine.getBusyReaderCount());
                Assert.assertEquals(0, engine.getBusyWriterCount());
            } finally {
                engine.clear();
            }
        }
    });
}
Also used : FilesFacade(io.questdb.std.FilesFacade) RecordCursorFactory(io.questdb.cairo.sql.RecordCursorFactory) LPSZ(io.questdb.std.str.LPSZ) FilesFacadeImpl(io.questdb.std.FilesFacadeImpl) Test(org.junit.Test)

Aggregations

FilesFacadeImpl (io.questdb.std.FilesFacadeImpl)48 Test (org.junit.Test)46 LPSZ (io.questdb.std.str.LPSZ)35 FilesFacade (io.questdb.std.FilesFacade)14 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)7 Path (io.questdb.std.str.Path)4 RecordCursorFactory (io.questdb.cairo.sql.RecordCursorFactory)3 AbstractGriffinTest (io.questdb.griffin.AbstractGriffinTest)3 SqlCompiler (io.questdb.griffin.SqlCompiler)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 MemoryMARW (io.questdb.cairo.vm.api.MemoryMARW)1 LineTcpSender (io.questdb.cutlass.line.LineTcpSender)1 SqlException (io.questdb.griffin.SqlException)1 BindVariableServiceImpl (io.questdb.griffin.engine.functions.bind.BindVariableServiceImpl)1 Rnd (io.questdb.std.Rnd)1 DateFormat (io.questdb.std.datetime.DateFormat)1 TimestampFormatCompiler (io.questdb.std.datetime.microtime.TimestampFormatCompiler)1 File (java.io.File)1