2023-11-06 monetdb-事务-insert-delta缓存-分析

news/2024/11/29 19:58:54/

摘要:

monetdb在事务处理时, 会将数据写入delta缓存中, 然后在commit时将数据写入wal文件, 随后由控制器决定何时将wal中的数据真正的写入BAT列文件中.

本文从delta缓存入手, 分析monetdb在事务处理中的细节.

SQL:

DML:

create table t1 (a int);

事务DDL:

START TRANSACTION;
insert into t1 values (4);
COMMIT;

trace日志:

mserver启动后第一次执行insert:

ALGO     monetdb5/mal/mal_interpreter.c:716             runMALsequence       calling querylog.define
ALGO     monetdb5/mal/mal_interpreter.c:687             runMALsequence       calling sql.transaction_begin
ALGO     monetdb5/mal/mal_interpreter.c:687             runMALsequence       calling sql.exportOperationALGO     monetdb5/mal/mal_interpreter.c:716             runMALsequence       calling querylog.define
ALGO     monetdb5/mal/mal_interpreter.c:687             runMALsequence       calling sql.mvc
ALGO     monetdb5/mal/mal_interpreter.c:687             runMALsequence       calling sql.claim
ALGO     monetdb5/mal/mal_interpreter.c:687             runMALsequence       calling sql.append
IO_      gdk/gdk_bbp.c:3156                             getBBPdescriptor     load tmp_550
IO_      gdk/gdk_storage.c:637                          DESCload             DESCload: 05/550
IO_      gdk/gdk_storage.c:536                          GDKload              GDKload: name=05/550.tail, ext=, mode 1
IO_      gdk/gdk_storage.c:558                          GDKload              read(dst 0x7f01e8040cc0, n_expected 12, fd 9) = 12
ALGO     gdk/gdk_bat.c:1039                             BUNappendmulti       tmp_550#3@0[int]P appending 1 values
ALGO     monetdb5/mal/mal_interpreter.c:687             runMALsequence       calling sql.depend
ALGO     monetdb5/mal/mal_interpreter.c:687             runMALsequence       calling sql.affectedRowsALGO     monetdb5/mal/mal_interpreter.c:716             runMALsequence       calling querylog.define
ALGO     monetdb5/mal/mal_interpreter.c:687             runMALsequence       calling sql.transaction_commit
IO_      gdk/gdk_bbp.c:3156                             getBBPdescriptor     load tmp_551
IO_      gdk/gdk_storage.c:637                          DESCload             DESCload: 05/551
IO_      gdk/gdk_storage.c:536                          GDKload              GDKload: name=05/551.tail, ext=, mode 1
IO_      gdk/gdk_storage.c:558                          GDKload              read(dst 0x7f01e8037d30, n_expected 4, fd 9) = 4
ALGO     monetdb5/mal/mal_interpreter.c:687             runMALsequence       calling sql.exportOperation

mserver启动后第二次连续执行两次insert:

monetdb5/mal/mal_interpreter.c:716             runMALsequence       calling querylog.define
monetdb5/mal/mal_interpreter.c:687             runMALsequence       calling sql.transaction_begin
monetdb5/mal/mal_interpreter.c:687             runMALsequence       calling sql.exportOperationmonetdb5/mal/mal_interpreter.c:716             runMALsequence       calling querylog.define
monetdb5/mal/mal_interpreter.c:687             runMALsequence       calling sql.mvc
monetdb5/mal/mal_interpreter.c:687             runMALsequence       calling sql.claim
monetdb5/mal/mal_interpreter.c:687             runMALsequence       calling sql.append
gdk/gdk_bat.c:1039                             BUNappendmulti       tmp_550#4@0[int]P appending 1 values
monetdb5/mal/mal_interpreter.c:687             runMALsequence       calling sql.depend
monetdb5/mal/mal_interpreter.c:687             runMALsequence       calling sql.affectedRowsmonetdb5/mal/mal_interpreter.c:716             runMALsequence       calling querylog.define
monetdb5/mal/mal_interpreter.c:687             runMALsequence       calling sql.mvc
monetdb5/mal/mal_interpreter.c:687             runMALsequence       calling sql.claim
monetdb5/mal/mal_interpreter.c:687             runMALsequence       calling sql.append
gdk/gdk_bat.c:1039                             BUNappendmulti       tmp_550#5@0[int]P appending 1 values
monetdb5/mal/mal_interpreter.c:687             runMALsequence       calling sql.depend
monetdb5/mal/mal_interpreter.c:687             runMALsequence       calling sql.affectedRowsmonetdb5/mal/mal_interpreter.c:716             runMALsequence       calling querylog.define
monetdb5/mal/mal_interpreter.c:687             runMALsequence       calling sql.transaction_commit
monetdb5/mal/mal_interpreter.c:687             runMALsequence       calling sql.exportOperation

核心处理:

BUNappendmulti

#0  BUNappendmulti (b=0x1a366680, values=0x7f01e803c600, count=1, force=true) at /root/work/monetdb-dev/trunk/monetdb-sep2022_sp3_release/gdk/gdk_bat.c:1028
#1  0x00007f0283fb03d6 in delta_append_val (tr=0x7f01e8004540, batp=0x7f027e1f51e8, id=7590, offset=6, i=0x7f01e803c600, cnt=1, storage_type=0x0, tt=6)at /root/work/monetdb-dev/trunk/monetdb-sep2022_sp3_release/sql/storage/bat/bat_storage.c:2319
#2  0x00007f0283fb0688 in append_col_execute (tr=0x7f01e8004540, delta=0x7f027e1f51e8, id=7590, offset=6, offsets=0x0, incoming_data=0x7f01e803c600, cnt=1, tt=6, storage_type=0x0)at /root/work/monetdb-dev/trunk/monetdb-sep2022_sp3_release/sql/storage/bat/bat_storage.c:2354
#3  0x00007f0283fb0969 in append_col (tr=0x7f01e8004540, c=0x1a571380, offset=6, offsets=0x0, data=0x7f01e803c600, cnt=1, tpe=6)at /root/work/monetdb-dev/trunk/monetdb-sep2022_sp3_release/sql/storage/bat/bat_storage.c:2384
#4  0x00007f0283e38a3c in mvc_append_wrap (cntxt=0x237c610, mb=0x7f01e8035660, stk=0x7f01e803c4d0, pci=0x7f01e8045000)at /root/work/monetdb-dev/trunk/monetdb-sep2022_sp3_release/sql/backends/monet5/sql.c:1842
#5  0x00007f0297637047 in runMALsequence (cntxt=0x237c610, mb=0x7f01e8035660, startpc=1, stoppc=0, stk=0x7f01e803c4d0, env=0x0, pcicaller=0x0)at /root/work/monetdb-dev/trunk/monetdb-sep2022_sp3_release/monetdb5/mal/mal_interpreter.c:688
#6  0x00007f02976357be in runMAL (cntxt=0x237c610, mb=0x7f01e8035660, mbcaller=0x0, env=0x0) at /root/work/monetdb-dev/trunk/monetdb-sep2022_sp3_release/monetdb5/mal/mal_interpreter.c:357
#7  0x00007f0283e5963b in SQLrun (c=0x237c610, m=0x7f01e80168d0) at /root/work/monetdb-dev/trunk/monetdb-sep2022_sp3_release/sql/backends/monet5/sql_execute.c:259
#8  0x00007f0283e5af37 in SQLengineIntern (c=0x237c610, be=0x7f01e8036150) at /root/work/monetdb-dev/trunk/monetdb-sep2022_sp3_release/sql/backends/monet5/sql_execute.c:709
#9  0x00007f0283e58505 in SQLengine (c=0x237c610) at /root/work/monetdb-dev/trunk/monetdb-sep2022_sp3_release/sql/backends/monet5/sql_scenario.c:1358
#10 0x00007f02976568c0 in runPhase (c=0x237c610, phase=4) at /root/work/monetdb-dev/trunk/monetdb-sep2022_sp3_release/monetdb5/mal/mal_scenario.c:453
#11 0x00007f0297656a2a in runScenarioBody (c=0x237c610, once=0) at /root/work/monetdb-dev/trunk/monetdb-sep2022_sp3_release/monetdb5/mal/mal_scenario.c:479
#12 0x00007f0297656c36 in runScenario (c=0x237c610, once=0) at /root/work/monetdb-dev/trunk/monetdb-sep2022_sp3_release/monetdb5/mal/mal_scenario.c:510
#13 0x00007f0297659048 in MSserveClient (c=0x237c610) at /root/work/monetdb-dev/trunk/monetdb-sep2022_sp3_release/monetdb5/mal/mal_session.c:589
#14 0x00007f02976588c1 in MSscheduleClient (command=0x7f01e8000b70 '\333' <repeats 199 times>, <incomplete sequence \333>..., challenge=0x7f027e1f5ce3 "HJBNRi7c", fin=0x7f01e8002b90, fout=0x7f01f0003e20, protocol=PROTOCOL_9, blocksize=8190) at /root/work/monetdb-dev/trunk/monetdb-sep2022_sp3_release/monetdb5/mal/mal_session.c:445
#15 0x00007f029771e232 in doChallenge (data=0x7f01f0000b70) at /root/work/monetdb-dev/trunk/monetdb-sep2022_sp3_release/monetdb5/modules/mal/mal_mapi.c:222
#16 0x00007f0296fcf749 in THRstarter (a=0x7f01f0006310) at /root/work/monetdb-dev/trunk/monetdb-sep2022_sp3_release/gdk/gdk_utils.c:1668
#17 0x00007f029704cb43 in thread_starter (arg=0x7f01f0006380) at /root/work/monetdb-dev/trunk/monetdb-sep2022_sp3_release/gdk/gdk_system.c:862
#18 0x00007f029658d1ca in start_thread () from /lib64/libpthread.so.0
#19 0x00007f02961f9e73 in clone () from /lib64/libc.so.6


http://www.ppmy.cn/news/1201202.html

相关文章

C#开发的OpenRA游戏之生命值

caimouse写于深圳 2023.11.6 C#开发的OpenRA游戏之生命值 前面已经分析了步兵攻击兵营的情况,通过子弹类不断射向兵营,就会导致兵营的损伤,这个损伤表现为生命值。定义如下: Health: HP: 60000 根据OpenRA的设计原则,每一个属性,就会生成一个Info信息类,再创建一个定…

【MongoDB】索引 - 数组字段的多键索引

数组字段创建索引时&#xff0c;MongoDB会为数组中的每个元素创建索引键&#xff08;多键索引&#xff09;&#xff0c;多键索引支持数组字段的高效查询。 一、准备工作 这里准备一些数据 db.shop.insertMany([{_id: 1, name: "水果店1", fruits: ["apple&qu…

Ubuntu下启动Apache对.htaccess 的支持步骤, 利用.htaccess绑定域名到子目录

Ubuntu下启动Apache对.htaccess 的支持步骤 1. 终端运行 sudo a2enmod 程序提示可供激活的模块名称&#xff0c;输入&#xff1a; rewrite 2. 修改/etc/apache2/sites-enabled/000-default (该链接指向的是站点配置文件) 把&#xff08;默认的www目录、或者需要应用.htacc…

java.sql.SQLSyntaxErrorException: Unknown column ‘id‘ in ‘field list‘

java.sql.SQLSyntaxErrorException: Unknown column ‘id‘ in ‘field list‘ 说明在执行sql语句的时候&#xff0c;操作表里没有id这个字段。 可能的情况&#xff1a; 表名错误。列名拼写错误&#xff1a;大小也要匹配表别名&#xff1a;如果在查询中使用了表别名&#xf…

python web框架 flask基础入门教程

python web框架 flask基础入门教程 今天我们写一个flask基础入门教程&#xff0c;当然也会覆盖很多重要的知识点&#xff0c;在这篇博客中&#xff0c;我们主要会讲解如下内容&#xff1a; 1、通过flask框架向web传输和接收参数 2、实现静态图片插入和图书上传 3、实现搭建…

Python教程:打印自己的名字

要打印的名字是&#xff1a;PYTHON …######… …#…#… …######… …#… …#… …#…#… …#…#… …##… …##… …##… …######… …##… …##… …##… …##… …#…#… …#…#… …######… …#…#… …#…#… …######… …#…#… …#…#… …#…#… …######… ……

QtC++与QLabel详解

介绍 QLabel 类是Qt中的一个用于显示文本或图像的控件类&#xff0c;通常用于用户界面中以提供静态文本或图片显示的功能。以下是对QLabel在Qt中的作用的详细解释&#xff1a; 文本和图像显示&#xff1a; QLabel 可以用来显示文本和图像。这使得它成为显示标签、标题、说明或…

QTcpServer 封装

来一段自封装&#xff0c;在用的QTcpserver,不用去找boost,或是poco,libevent……&#xff0c;也不用去从底层winsocket封装开始&#xff0c;真不用去那么折腾&#xff0c;放着QT自带的不用&#xff0c;那不仅是可惜&#xff0c;是辜负了QT团队的一片苦心…… #pragma once #i…