Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
Questdb
提交
55ee0a0e
Q
Questdb
项目概览
jobily
/
Questdb
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Q
Questdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
55ee0a0e
编写于
1月 25, 2021
作者:
V
Vlad Ilyushchenko
提交者:
GitHub
1月 25, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(cairo): create table race condition fix (#787)
上级
a6419407
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
112 addition
and
69 deletion
+112
-69
core/src/main/c/share/files.c
core/src/main/c/share/files.c
+4
-0
core/src/main/c/windows/files.c
core/src/main/c/windows/files.c
+7
-0
core/src/main/java/io/questdb/cairo/CairoEngine.java
core/src/main/java/io/questdb/cairo/CairoEngine.java
+23
-1
core/src/main/java/io/questdb/cairo/TableUtils.java
core/src/main/java/io/questdb/cairo/TableUtils.java
+57
-41
core/src/main/java/io/questdb/cutlass/line/tcp/LineTcpMeasurementScheduler.java
...questdb/cutlass/line/tcp/LineTcpMeasurementScheduler.java
+3
-2
core/src/main/java/io/questdb/cutlass/text/CairoTextWriter.java
...rc/main/java/io/questdb/cutlass/text/CairoTextWriter.java
+6
-14
core/src/main/java/io/questdb/griffin/SqlCompiler.java
core/src/main/java/io/questdb/griffin/SqlCompiler.java
+2
-2
core/src/main/java/io/questdb/std/Files.java
core/src/main/java/io/questdb/std/Files.java
+2
-8
core/src/main/java/io/questdb/std/FilesFacade.java
core/src/main/java/io/questdb/std/FilesFacade.java
+2
-0
core/src/main/java/io/questdb/std/FilesFacadeImpl.java
core/src/main/java/io/questdb/std/FilesFacadeImpl.java
+5
-0
core/src/main/resources/io/questdb/bin/linux/libquestdb.so
core/src/main/resources/io/questdb/bin/linux/libquestdb.so
+0
-0
core/src/main/resources/io/questdb/bin/osx/libquestdb.dylib
core/src/main/resources/io/questdb/bin/osx/libquestdb.dylib
+0
-0
core/src/main/resources/io/questdb/bin/windows/libquestdb.dll
.../src/main/resources/io/questdb/bin/windows/libquestdb.dll
+0
-0
ui/package-lock.json
ui/package-lock.json
+1
-1
未找到文件。
core/src/main/c/share/files.c
浏览文件 @
55ee0a0e
...
...
@@ -236,6 +236,10 @@ JNIEXPORT jint JNICALL Java_io_questdb_std_Files_msync(JNIEnv *e, jclass cl, jlo
return
msync
((
void
*
)
addr
,
len
,
async
?
MS_ASYNC
:
MS_SYNC
);
}
JNIEXPORT
jint
JNICALL
Java_io_questdb_std_Files_fsync
(
JNIEnv
*
e
,
jclass
cl
,
jlong
fd
)
{
return
fsync
((
int
)
fd
);
}
JNIEXPORT
jboolean
JNICALL
Java_io_questdb_std_Files_remove
(
JNIEnv
*
e
,
jclass
cl
,
jlong
lpsz
)
{
return
(
jboolean
)
(
remove
((
const
char
*
)
lpsz
)
==
0
);
...
...
core/src/main/c/windows/files.c
浏览文件 @
55ee0a0e
...
...
@@ -147,6 +147,13 @@ JNIEXPORT jint JNICALL Java_io_questdb_std_Files_msync(JNIEnv *e, jclass cl, jlo
return
0
;
}
JNIEXPORT
jint
JNICALL
Java_io_questdb_std_Files_fsync
(
JNIEnv
*
e
,
jclass
cl
,
jlong
fd
)
{
// Windows does not seem to have fsync or cannot fsync directory.
// To be fair we never saw our destructive test fail on windows,
// which leads to an assumption that all directory changes on windows are synchronous.
return
-
1
;
}
JNIEXPORT
jboolean
JNICALL
Java_io_questdb_std_Files_setLastModified
(
JNIEnv
*
e
,
jclass
cl
,
jlong
lpszName
,
jlong
millis
)
{
...
...
core/src/main/java/io/questdb/cairo/CairoEngine.java
浏览文件 @
55ee0a0e
...
...
@@ -105,7 +105,7 @@ public class CairoEngine implements Closeable, WriterSource {
configuration
.
getFilesFacade
().
close
(
tableIndexFd
);
}
public
void
createTable
(
public
void
createTable
Unsafe
(
CairoSecurityContext
securityContext
,
AppendMemory
mem
,
Path
path
,
...
...
@@ -123,6 +123,28 @@ public class CairoEngine implements Closeable, WriterSource {
);
}
public
void
createTable
(
CairoSecurityContext
securityContext
,
AppendMemory
mem
,
Path
path
,
TableStructure
struct
)
{
if
(
lock
(
securityContext
,
struct
.
getTableName
()))
{
try
{
createTableUnsafe
(
securityContext
,
mem
,
path
,
struct
);
}
finally
{
unlock
(
securityContext
,
struct
.
getTableName
(),
null
);
}
}
else
{
throw
EntryUnavailableException
.
INSTANCE
;
}
}
public
TableWriter
getBackupWriter
(
CairoSecurityContext
securityContext
,
CharSequence
tableName
,
...
...
core/src/main/java/io/questdb/cairo/TableUtils.java
浏览文件 @
55ee0a0e
...
...
@@ -130,6 +130,7 @@ public final class TableUtils {
int
tableVersion
,
int
tableId
)
{
LOG
.
debug
().
$
(
"create table [name="
).
$
(
structure
.
getTableName
()).
$
(
']'
).
$
();
path
.
of
(
root
).
concat
(
structure
.
getTableName
());
if
(
ff
.
mkdirs
(
path
.
put
(
Files
.
SEPARATOR
).
$
(),
mkDirMode
)
!=
0
)
{
...
...
@@ -138,52 +139,67 @@ public final class TableUtils {
final
int
rootLen
=
path
.
length
();
try
(
AppendMemory
mem
=
memory
)
{
mem
.
of
(
ff
,
path
.
trimTo
(
rootLen
).
concat
(
META_FILE_NAME
).
$
(),
ff
.
getPageSize
());
final
int
count
=
structure
.
getColumnCount
();
mem
.
putInt
(
count
);
mem
.
putInt
(
structure
.
getPartitionBy
());
mem
.
putInt
(
structure
.
getTimestampIndex
());
mem
.
putInt
(
tableVersion
);
mem
.
putInt
(
tableId
);
mem
.
jumpTo
(
TableUtils
.
META_OFFSET_COLUMN_TYPES
);
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
mem
.
putByte
((
byte
)
structure
.
getColumnType
(
i
));
long
flags
=
0
;
if
(
structure
.
isIndexed
(
i
))
{
flags
|=
META_FLAG_BIT_INDEXED
;
}
final
long
dirFd
=
!
ff
.
isRestrictedFileSystem
()
?
ff
.
openRO
(
path
.
$
())
:
0
;
if
(
dirFd
!=
-
1
)
{
try
(
AppendMemory
mem
=
memory
)
{
mem
.
of
(
ff
,
path
.
trimTo
(
rootLen
).
concat
(
META_FILE_NAME
).
$
(),
ff
.
getPageSize
());
final
int
count
=
structure
.
getColumnCount
();
mem
.
putInt
(
count
);
mem
.
putInt
(
structure
.
getPartitionBy
());
mem
.
putInt
(
structure
.
getTimestampIndex
());
mem
.
putInt
(
tableVersion
);
mem
.
putInt
(
tableId
);
mem
.
jumpTo
(
TableUtils
.
META_OFFSET_COLUMN_TYPES
);
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
mem
.
putByte
((
byte
)
structure
.
getColumnType
(
i
));
long
flags
=
0
;
if
(
structure
.
isIndexed
(
i
))
{
flags
|=
META_FLAG_BIT_INDEXED
;
}
if
(
structure
.
isSequential
(
i
))
{
flags
|=
META_FLAG_BIT_SEQUENTIAL
;
}
if
(
structure
.
isSequential
(
i
))
{
flags
|=
META_FLAG_BIT_SEQUENTIAL
;
}
mem
.
putLong
(
flags
);
mem
.
putInt
(
structure
.
getIndexBlockCapacity
(
i
));
mem
.
skip
(
META_COLUMN_DATA_RESERVED
);
// reserved
}
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
mem
.
putStr
(
structure
.
getColumnName
(
i
));
}
mem
.
putLong
(
flags
);
mem
.
putInt
(
structure
.
getIndexBlockCapacity
(
i
));
mem
.
skip
(
META_COLUMN_DATA_RESERVED
);
// reserved
}
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
mem
.
putStr
(
structure
.
getColumnName
(
i
));
}
// create symbol maps
int
symbolMapCount
=
0
;
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
if
(
structure
.
getColumnType
(
i
)
==
ColumnType
.
SYMBOL
)
{
SymbolMapWriter
.
createSymbolMapFiles
(
ff
,
mem
,
path
.
trimTo
(
rootLen
),
structure
.
getColumnName
(
i
),
structure
.
getSymbolCapacity
(
i
),
structure
.
getSymbolCacheFlag
(
i
)
);
symbolMapCount
++;
// create symbol maps
int
symbolMapCount
=
0
;
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
if
(
structure
.
getColumnType
(
i
)
==
ColumnType
.
SYMBOL
)
{
SymbolMapWriter
.
createSymbolMapFiles
(
ff
,
mem
,
path
.
trimTo
(
rootLen
),
structure
.
getColumnName
(
i
),
structure
.
getSymbolCapacity
(
i
),
structure
.
getSymbolCacheFlag
(
i
)
);
symbolMapCount
++;
}
}
mem
.
of
(
ff
,
path
.
trimTo
(
rootLen
).
concat
(
TXN_FILE_NAME
).
$
(),
ff
.
getPageSize
());
TableUtils
.
resetTxn
(
mem
,
symbolMapCount
,
0L
,
INITIAL_TXN
);
}
finally
{
if
(
dirFd
>
0
)
{
if
(
ff
.
fsync
(
dirFd
)
!=
0
)
{
LOG
.
error
()
.
$
(
"could not fsync [fd="
).
$
(
dirFd
)
.
$
(
", errno="
).
$
(
ff
.
errno
())
.
$
(
']'
).
$
();
}
ff
.
close
(
dirFd
);
}
}
mem
.
of
(
ff
,
path
.
trimTo
(
rootLen
).
concat
(
TXN_FILE_NAME
).
$
(),
ff
.
getPageSize
());
TableUtils
.
resetTxn
(
mem
,
symbolMapCount
,
0L
,
INITIAL_TXN
);
}
else
{
throw
CairoException
.
instance
(
ff
.
errno
()).
put
(
"Could not open dir [path="
).
put
(
path
).
put
(
']'
);
}
}
...
...
core/src/main/java/io/questdb/cutlass/line/tcp/LineTcpMeasurementScheduler.java
浏览文件 @
55ee0a0e
...
...
@@ -781,11 +781,12 @@ class LineTcpMeasurementScheduler implements Closeable {
}
preprocessEvent
(
event
);
engine
.
createTable
(
engine
.
createTable
Unsafe
(
securityContext
,
appendMemory
,
path
,
tableStructureAdapter
.
of
(
event
,
this
));
tableStructureAdapter
.
of
(
event
,
this
)
);
int
nValues
=
event
.
getNValues
();
for
(
int
n
=
0
;
n
<
nValues
;
n
++)
{
colIndexMappings
.
set
(
n
,
n
);
...
...
core/src/main/java/io/questdb/cutlass/text/CairoTextWriter.java
浏览文件 @
55ee0a0e
...
...
@@ -208,20 +208,12 @@ public class CairoTextWriter implements Closeable, Mutable {
ObjList
<
TypeAdapter
>
detectedTypes
,
CairoSecurityContext
cairoSecurityContext
)
throws
TextException
{
if
(
engine
.
lock
(
cairoSecurityContext
,
tableName
))
{
try
{
engine
.
createTable
(
cairoSecurityContext
,
appendMemory
,
path
,
tableStructureAdapter
.
of
(
names
,
detectedTypes
)
);
}
finally
{
engine
.
unlock
(
cairoSecurityContext
,
tableName
,
null
);
}
}
else
{
throw
EntryUnavailableException
.
INSTANCE
;
}
engine
.
createTable
(
cairoSecurityContext
,
appendMemory
,
path
,
tableStructureAdapter
.
of
(
names
,
detectedTypes
)
);
this
.
types
=
detectedTypes
;
}
...
...
core/src/main/java/io/questdb/griffin/SqlCompiler.java
浏览文件 @
55ee0a0e
...
...
@@ -1405,7 +1405,7 @@ public class SqlCompiler implements Closeable {
try
{
if
(
createTableModel
.
getQueryModel
()
==
null
)
{
engine
.
createTable
(
executionContext
.
getCairoSecurityContext
(),
mem
,
path
,
createTableModel
);
engine
.
createTable
Unsafe
(
executionContext
.
getCairoSecurityContext
(),
mem
,
path
,
createTableModel
);
}
else
{
writer
=
createTableFromCursor
(
createTableModel
,
executionContext
);
}
...
...
@@ -1430,7 +1430,7 @@ public class SqlCompiler implements Closeable {
typeCast
.
clear
();
final
RecordMetadata
metadata
=
factory
.
getMetadata
();
validateTableModelAndCreateTypeCast
(
model
,
metadata
,
typeCast
);
engine
.
createTable
(
engine
.
createTable
Unsafe
(
executionContext
.
getCairoSecurityContext
(),
mem
,
path
,
...
...
core/src/main/java/io/questdb/std/Files.java
浏览文件 @
55ee0a0e
...
...
@@ -36,15 +36,7 @@ public final class Files {
public
static
final
Charset
UTF_8
;
public
static
final
long
PAGE_SIZE
;
// public static final int DT_UNKNOWN = 0;
// public static final int DT_FIFO = 1;
// public static final int DT_CHR = 2;
public
static
final
int
DT_DIR
=
4
;
// public static final int DT_BLK = 6;
// public static final int DT_REG = 8;
// public static final int DT_LNK = 10;
// public static final int DT_SOCK = 12;
// public static final int DT_WHT = 14;
public
static
final
int
MAP_RO
=
1
;
public
static
final
int
MAP_RW
=
2
;
...
...
@@ -116,6 +108,8 @@ public final class Files {
public
static
native
int
msync
(
long
addr
,
long
len
,
boolean
async
);
public
static
native
int
fsync
(
long
fd
);
public
static
int
mkdir
(
LPSZ
path
,
int
mode
)
{
return
mkdir
(
path
.
address
(),
mode
);
}
...
...
core/src/main/java/io/questdb/std/FilesFacade.java
浏览文件 @
55ee0a0e
...
...
@@ -54,6 +54,8 @@ public interface FilesFacade {
int
msync
(
long
addr
,
long
len
,
boolean
async
);
int
fsync
(
long
fd
);
long
getMapPageSize
();
long
getOpenFileCount
();
...
...
core/src/main/java/io/questdb/std/FilesFacadeImpl.java
浏览文件 @
55ee0a0e
...
...
@@ -102,6 +102,11 @@ public class FilesFacadeImpl implements FilesFacade {
return
Files
.
msync
(
addr
,
len
,
async
);
}
@Override
public
int
fsync
(
long
fd
)
{
return
Files
.
fsync
(
fd
);
}
@Override
public
long
getMapPageSize
()
{
if
(
mapPageSize
==
0
)
{
...
...
core/src/main/resources/io/questdb/bin/linux/libquestdb.so
浏览文件 @
55ee0a0e
无法预览此类型文件
core/src/main/resources/io/questdb/bin/osx/libquestdb.dylib
浏览文件 @
55ee0a0e
无法预览此类型文件
core/src/main/resources/io/questdb/bin/windows/libquestdb.dll
浏览文件 @
55ee0a0e
无法预览此类型文件
ui/package-lock.json
浏览文件 @
55ee0a0e
...
...
@@ -2954,7 +2954,7 @@
"buffer-from": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz",
"integrity": "sha
512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A=
=",
"integrity": "sha
1-MnE7wCj3XAL9txDXx7zsHyxgcO8
=",
"dev": true
},
"buffer-indexof": {
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录