首页 \ 问答 \ PostgreSQL自动增量是否可以实现竞争条件(Are race conditions possible with PostgreSQL auto-increment)

PostgreSQL自动增量是否可以实现竞争条件(Are race conditions possible with PostgreSQL auto-increment)

是否存在使用典型自动增量字段在表中创建的记录可用于按顺序读取的条件?

例如,当值为9的记录对选择查询不可见时,值为10的记录是否会出现在选择查询的结果中?

我的问题的目的是......我想知道使用从一个查询中检索到的最大值作为下限来识别以后查询中先前未检索的值是否可靠,或者是否可能错过一行?

如果在某些情况下可能存在这种竞争条件,那么可以用于对该问题免疫的选择查询的任何隔离级别是什么?


Are there any conditions under which records created in a table using a typical auto-increment field would be available for read out of sequence?

For instance, could a record with value 10 ever appear in the result of a select query when the record with value 9 is not yet visible to a select query?

The purpose for my question is… I want to know if it is reliable to use the maximum value retrieved from one query as the lower bound to identify previously unretrieved values in a later query, or could that potentially miss a row?

If that kind of race condition is possible under some circumstances, then are any of the isolation levels that can be used for the select queries that are immune to that problem?


原文:https://stackoverflow.com/questions/44174231
更新时间:2023-07-26 11:07

最满意答案

mail()是一个黑盒子。 您告诉PHP尝试发送邮件,但主机已配置PHP以执行此操作。

很可能只是在你的情况下调用sendmail。 该机器上的邮件队列也很可能不是世界上最快的。 共享主机通常超载。

您应该做的第一件事是询问您的主机邮件延迟。 也许出了点问题,他们可以修复它。 或者他们可能只是告诉你,一分半钟的等待时间不长。

还有很多其他选项,主要是以向您提供SMTP服务的公司的形式。 我不推荐一个,但我可以建议你跳到你最喜欢的搜索引擎,并寻找“smtp服务”。 我最近开始使用Amazon Simple Email Service 。 它应该是快速和良好的维护,它肯定是便宜的。

所有这些选项可能需要对您进行一些配置更改。 例如,您需要设置自定义DNS记录(对于DKIMSPF ),以确保来自第三方提供商的邮件不会自动标记为垃圾邮件。

使用SMTP与PHP很容易。 那里有很多邮件生成选项。 我个人最喜欢的是SwiftMailer 。 它甚至还有Amazon SES传输选项

当然,最后一个选项是获取您自己的虚拟专用服务器或专用服务器,这将允许您根据需要配置外发邮件,但代价是需要知道如何维护该服务器。


编辑: 相关编码恐怖帖的强制性链接


mail() is a black box. You're telling PHP to try sending a mail however the host has configured PHP to do so.

It's very likely that it's just calling sendmail in your case. It's also very likely that the mail queue on that machine isn't the fastest in the world. Shared hosting machines are often overloaded.

The very first thing you should do is ask your host about the mail delay. Perhaps something is wrong, and they can fix it. Or they might just tell you that a minute and a half is not a long time to wait.

There are lots of other options, mostly in the form of companies that provide an SMTP service to you. I can't recommend one, but I can recommend that you pop over to your favorite search engine and look for "smtp service." I've recently starting working with Amazon Simple Email Service. It's supposed to be fast and well-maintained, and it's certainly inexpensive.

All of those options are likely going to require some configuration changes on your end. For example, you'll want to set up custom DNS records (for DKIM and SPF) to ensure that mail from a third party provider isn't automatically flagged as spam.

Using SMTP with PHP is dead easy. There are plenty of mail generating options out there. My personal favorite is SwiftMailer. It even has a transport option for Amazon SES.

The final option, of course, is grabbing your own virtual private server or dedicated server, which will let you configure outgoing mail as you desire, at the cost of needing to know how to maintain that server.


Edit: Obligatory link to relevant Coding Horror post.

相关问答

更多
  • 您可以通过电子邮件或SNS通知有关退回/投诉等信息。 要获得SNS通知,请阅读: http : //docs.aws.amazon.com/ses/latest/DeveloperGuide/configure-sns-notifications.html 获取电子邮件通知请阅读: http : //docs.aws.amazon.com/ses/latest/DeveloperGuide/notifications-via-email.html You can be notified either via ...
  • 尝试从请求正文中删除CaptiveInfo节点(同时删除位于其中的ClientUserId节点)。 如果您从请求中忽略这些元素,DocuSign应将签名邀请电子邮件发送给收件人。 Try removing the CaptiveInfo node from the request body (also removing the ClientUserId node that's located within it). DocuSign should send the signing invitation em ...
  • send_mail()的返回值是一个布尔值,用于指示消息是否已成功发送。 您可以编写一个迭代收件人列表的函数,调用send_mail(),将成功的交付附加到一个列表,并将不成功的收件人附加到另一个列表。 然后,您可以使用该信息编写消息。 像这样的东西: recipients = [ ... ] # list of people you're sending the email to successful_recipients = [] unsuccessful_recipients ...
  • 基本上,在这种情况下有三个与您相关的标题。 from标题标识电子邮件来自谁的来源,人类发起的回复将针对的回复标题以及最后发送自动发送状态邮件的返回路径 。 三个领域的每一个都可以不同。 顺便说一下,如果这些标题中的任何一个使用发送SMTP服务器IP地址未解析到的域,并且该域未包含在您的SPF记录中,则您的电子邮件将最终存在于垃圾邮件文件夹中的可能性更大 。 Essentially there are three headers of relevance to you for this scenario. T ...
  • 我终于设法怎么做了.. 为简洁起见,我显示过于简化的代码,请参见下文: 控制器: [HttpPost] public ActionResult ContactUs(ContactUsModel model) { new ExternalApiCalls().MailContactUs(model); return RedirectToAction("ContactUsSuccess", "Account"); } 助手班级: pub ...
  • Anymail具有一个send_at消息属性,用于对支持它的ESP(包括Mailgun)的预定发送进行标准化。 Anymail has a send_at message attribute which normalizes scheduled sending across the ESPs that support it, including Mailgun.
  • mail()是一个黑盒子。 您告诉PHP尝试发送邮件,但主机已配置PHP以执行此操作。 它很可能只是在你的情况下调用sendmail。 该机器上的邮件队列也很可能不是世界上最快的。 共享主机通常超载。 您应该做的第一件事是询问您的主机邮件延迟。 也许出了点问题,他们可以修复它。 或者他们可能只是告诉你,一分半钟的等待时间不长。 还有很多其他选项,主要是以向您提供SMTP服务的公司的形式。 我不推荐一个,但我可以建议你跳到你最喜欢的搜索引擎,并寻找“smtp服务”。 我最近开始使用Amazon Simple ...
  • 简短回答:是的 Short answer: Yes
  • 据我所知,没有任何内容可以将信息返回给ActivityResult,后者可以说明电子邮件是正确发送还是用户取消或保存为草稿。 虽然我从未试图详细了解更多内容。 所以我的答案是否定的 As Far As I Know there is nothing that returns back the information to ActivityResult which can state wheather the Email was send correctly or user canceled or saved ...
  • 正如@userfuser建议的那样,这是我稍微修改后的评论作为答案: 由于您的要求与配置选项的语义相矛盾,因此您唯一的选择似乎是在邮件发送组件中添加一些逻辑。 我确信您将能够以编程方式提取白名单和其他选项,以便您可以构建边缘案例。 As @userfuser suggested, here is my slightly altered comment as an answer: Since your requirement contradicts the semantics of the configura ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)