首页 \ 问答 \ MySQL Workbench:启动事务似乎在回滚之前提交(MySQL Workbench: Start Transaction seems to be committed before rollback)

MySQL Workbench:启动事务似乎在回滚之前提交(MySQL Workbench: Start Transaction seems to be committed before rollback)

我写了一堆删除语句并将它们包装在一个事务中:

start transaction;
delete a...
delete b...
delete c...
rollback;

我的想法是,我希望删除发生在事务中,该事务将在完成时回滚。 如果步骤失败,我希望成功的步骤也可以回滚。

令我懊恼的是delete a工作,删除几千行, delete b失败,但当我重新声明时,所有来自a的记录似乎都消失了。

这是因为交易还在开放吗? 我尝试过:

set session transaction isolation level read committed;
select a.*

并回到零行,所以我认为情况并非如此。 删除是否成功? 如果是这样,我怎样才能防止这种情况发生,直到我能保证完整的查询?


I wrote a bunch of delete statements and wrapped them in a transaction:

start transaction;
delete a...
delete b...
delete c...
rollback;

The idea is I would want the deletes to occur inside a transaction which would rollback upon completion. If a step failed along the way, I would want the successful steps to be rolled back as well.

To my chagrin delete a worked, removing a few thousand rows, delete b failed, but when I reran the statements all the records from a appeared to be gone.

Is this because the transaction is still open? I tried doing:

set session transaction isolation level read committed;
select a.*

and got back zero rows so I think that is not the case. Was the successful a delete committed? And if so, how do I prevent that from happening until I can guarantee a full working query?


原文:https://stackoverflow.com/questions/37400283
更新时间:2022-05-15 14:05

最满意答案

这是一个想法的骨架:

#!/bin/bash
exec 5< <(sleep 4; pwd)
while true
do
  if
    read -t 0 -u 5 dummy
  then
    echo Data available
    cat <&5
    break
  else
    echo No data
  fi
  sleep 1
done

从Bash参考手册:

如果timeout为0,则read立即返回,而不尝试读取和数据。 如果输入在指定的文件描述符上可用,则退出状态为0,否则为非零。

想法是使用带有-t 0读取(具有零超时)和-u 5 (从文件描述符5读取)以立即检查数据可用性。

当然,这只是展示概念的玩具循环。


Here is the skeleton of an idea :

#!/bin/bash
exec 5< <(sleep 4; pwd)
while true
do
  if
    read -t 0 -u 5 dummy
  then
    echo Data available
    cat <&5
    break
  else
    echo No data
  fi
  sleep 1
done

From the Bash reference manual :

If timeout is 0, read returns immediately, without trying to read and data. The exit status is 0 if input is available on the specified file descriptor, non-zero otherwise.

The idea is to use read with -t 0 (to have zero timeout) and -u 5 (read from file descriptor 5) to instantly check for data availability.

Of course this is just a toy loop to demonstrate the concept.

相关问答

更多
  • fcntl(fd, F_GETFD)是检查fd是否为有效的打开文件描述符的最经济的方法。 如果您需要批量检查,使用poll为零超时,并且events成员设置为0,并在返回后在POLLNVAL中检查POLLNVAL更有效。 这就是说,“检查给定资源句柄是否仍然有效”的操作几乎总是从根本上不正确。 资源句柄释放后(例如fd close d),其值可能会被重新分配给您分配的下一个此类资源。 如果有任何剩余的引用可能会被使用,他们会错误地操作新资源而不是旧资源。 因此,真正的答案可能是:如果您不知道程序的逻辑,那么 ...
  • 我假设你说在关闭套接字后你的应用程序可以继续合理地继续运行吗? 看起来更好的方法是获得一个中介线程,通知来自任何工作线程的套接字关闭请求,通知其他线程该套接字现在已经死了,并负责关闭套接字本身。 这消除了对失败原因的担忧,因为它全部在单个线程中处理。 I assume you're saying it's possible for your application to reasonably continue after shutting down the socket? It seems that a b ...
  • 将两个重定向器放在同一行上: cat 3<<222889 0<&3 I am reading a string into file descriptor 3 which is copied to standrad input 222889 然后cat只输出here文档中的所有内容。 Place both redirectors on the same line: cat 3<<222889 0<&3 I am reading a string into file descriptor 3 which ...
  • 根据 Socket#getOutputStream类的文档 : 的getOutputStream OutputStream getOutputStream() 返回此套接字的输出流。 如果此套接字具有关联的通道,则生成的输出流将其所有操作委托给通道。 如果通道处于非阻塞模式,则输出流的写入操作将抛出IllegalBlockingModeException。 关闭返回的OutputStream将关闭关联的套接字。 这里需要注意的是: 关闭返回的OutputStream将关闭关联的套接字。 在您的代码中,在您写 ...
  • 您希望fcntl()检查fd上的读/写设置: #include #include int r; r = fcntl(fd, F_GETFL); if (r == -1) /* Error */ if (r & O_RDONLY) /* Read Only */ else if (r & O_WRONLY) /* Write Only */ else if (r & O_RDWR) /* Read/Write */ ...
  • 我不知道有多少个字符存储在管道的读取端 不要担心。 有一些优点(例如原子性)不会尝试写入/读取超过PIPE_BUF字节。 实际上,无论如何,你可能会得到一堆简短的阅读。 #define READ_BUFFER_SIZE PIPE_BUF unsigned char mybuffer[READ_BUFFER_SIZE]; ssize_t bytesread = 1; while ((bytesread = read(pipefd, mybuffer, READ_BUFFER_SIZE)) > 0) { ...
  • 是的,你可以使用串口完成,没问题。 您也可以使用常规文件来执行此操作,但这可能会让您感到困惑,因为您必须仔细管理文件的内容,以便读取器和写入器不会相互踩踏并特别小心地管理搜索指针(使用不依赖于搜索指针的pread()和pwrite() )。 显然,由于串行端口具有独立的输入和输出方向,并且没有寻道指针的概念,因此它更直接。 Yes, you can do that with a serial port, no problem. You could do it with a regular file too, ...
  • 我相信你是对的,有时文件描述符可能已经在使用中。 我从http://tldp.org/LDP/abs/html/io-redirection.html#FTN.AEN17716得到了这个 “使用文件描述符5可能会导致问题。当Bash创建子进程时,与exec一样,子进程继承fd 5(请参阅Chet Ramey的归档电子邮件, SUBJECT:RE:文件描述符5保持打开状态 )。独自一人。“ 对此的解决方案在bash手册的第3.6节第2节中有详细说明。 可以在文件描述符号之前的每个重定向可以改为在{varnam ...
  • 这是一个想法的骨架: #!/bin/bash exec 5< <(sleep 4; pwd) while true do if read -t 0 -u 5 dummy then echo Data available cat <&5 break else echo No data fi sleep 1 done 从Bash参考手册: 如果timeout为0,则read立即返回,而不尝试读取和数据。 如果输入在指定的文件描述符上可用,则退出状态为 ...
  • 您似乎将DisplayMsgFun对象的副本传递给std::thread构造函数,这意味着原始副本被销毁,并根据您的析构函数自动调用::close 。 You appear to be passing a copy of the DisplayMsgFun object to the std::thread constructor, which means that the original copy gets destroyed, automatically calling ::close per you ...

相关文章

更多

最新问答

更多
  • sp_updatestats是否导致SQL Server 2005中无法访问表?(Does sp_updatestats cause tables to be inaccessible in SQL Server 2005?)
  • 如何创建一个可以与持续运行的服务交互的CLI,类似于MySQL的shell?(How to create a CLI that can interact with a continuously running service, similar to MySQL's shell?)
  • AESGCM解密失败的MAC(AESGCM decryption failing with MAC)
  • Zurb Foundation 4 - 嵌套网格对齐问题(Zurb Foundation 4 - Nested grid alignment issues)
  • 湖北京山哪里有修平板计算机的
  • SimplePie问题(SimplePie Problem)
  • 在不同的任务中,我们可以同时使用多少“上下文”?(How many 'context' we can use at a time simultaneously in different tasks?)
  • HTML / Javascript:从子目录启用文件夹访问(HTML/Javascript: Enabling folder access from a subdirectory)
  • 为什么我会收到链接错误?(Why do I get a linker error?)
  • 如何正确定义析构函数(How to properly define destructor)
  • 垂直切换菜单打开第3级父级。(Vertical toggle menu 3rd level parent stay opened. jQuery)
  • 类型不匹配 - JavaScript(Type mismatch - JavaScript)
  • 为什么当我将模型传递给我的.Net MVC 4控制器操作时,它坚持在部分更新中使用它?(Why is it that when I pass a Model to my .Net MVC 4 Controller Action it insists on using it in the Partial Update?)
  • 在使用熊猫和statsmodels时拉取变量名称(Pulling variable names when using pandas and statsmodels)
  • 如何开启mysql计划事件
  • 检查数组的总和是否大于最大数,反之亦然javascript(checking if sum of array is greater than max number and vice versa javascript)
  • 使用OpenGL ES绘制轮廓(Drawing Outline with OpenGL ES)
  • java日历格式(java Calendar format)
  • Python PANDAS:将pandas / numpy转换为dask数据框/数组(Python PANDAS: Converting from pandas/numpy to dask dataframe/array)
  • 如何搜索附加在elasticsearch索引中的文档的内容(How to search a content of a document attached in elasticsearch index)
  • LinQ to Entities:做相反的查询(LinQ to Entities: Doing the opposite query)
  • 从ExtJs 4.1商店中删除记录时会触发哪些事件(Which events get fired when a record is removed from ExtJs 4.1 store)
  • 运行javascript后如何截取网页截图[关闭](How to take screenshot of a webpage after running javascript [closed])
  • 如何使用GlassFish打印完整的堆栈跟踪?(How can I print the full stack trace with GlassFish?)
  • 如何获取某个exe应用程序的出站HTTP请求?(how to get the outbound HTTP request of a certain exe application?)
  • 嗨,Android重叠背景片段和膨胀异常(Hi, Android overlapping background fragment and inflate exception)
  • Assimp详细说明typedef(Assimp elaborated type refers to typedef)
  • 初始化继承类中不同对象的列表(initialize list of different objects in inherited class)
  • 使用jquery ajax在gridview行中保存星级评分(Save star rating in a gridview row using jquery ajax)
  • Geoxml3 groundOverlay zIndex(Geoxml3 groundOverlay zIndex)