You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

137 lines
5.6 KiB

[ADD] ir_sequence_standard_default: Use Standard instead No Gap sequence Set the implementation to "Standard" in all your current Sequences (ir.sequence) and all new sequences are created as "Standard" by default instead of "No Gap" implementation. **What's the problem Sequences with "No Gap" Implementation?** "No Gap" is the default value of sequences in Odoo. However, this kind of sequences cause more locks and can turn a database slow. Taking as example an invoice, if you assign an invoice number to one record, but it sill not finish the process, this process must end in order to another invoice could assign a new number and there was no gaps between the invoice numbers. It seems to be good at first sight. But the problem start when there is and chained process. Imagine that there is one user that executes a process that produces 100 invoices and these at the same time produces 100 journal entries that also use a consecutive (no gap) sequence. And also those invoices are sent to sign with and external institution (that could take 2 seconds in giving a response because of internet latency or server load), and maybe they made another calculations that makes them to take 5 seconds more for each invoice, and all this is chained to one single transaction. This means that for 8.5 minutes anybody else could confirm invoices, neither journal entries of the involved journals. Now, think there is 20 users that have to execute a similar process. The problem turns exponential. If another user comes to make an operation with the same jornal it will thrown a concurrency failure. You can mitigate it if you segment each transaction and don't chain them. It means, making commit for each invoice or process. It reduces the probability that there is a concurrency error or a lock wait. However, it still not solve it completely. **Why to use Sequences with "Standard" Implementation?** If you use the standard sequence of PosgreSQL, it doesn't lock because at the moment the request is done, the next sequence number it is changed in an isolated transaction, and it have not to wait the other transaction to end. However, if the transaction produces a rollback, this sequence isn't reverted, it means, it's lost. It may be not not serious because when you cancel or remove records that number is lost too. **What this module does?** To eliminate completely that concurrency/slowness problem, this module changes all the sequences (ir.sequence) implementation from "No Gap" to "Standard" with the awareness that it will skip numbers. In the majority of database models and many users projects there is no problem with that jump occurs. Also, all newly created sequences will be by default in "Standard" implementation.
5 years ago
  1. ==============================
  2. IrSequence Standard by Default
  3. ==============================
  4. .. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  5. !! This file is generated by oca-gen-addon-readme !!
  6. !! changes will be overwritten. !!
  7. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  8. .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
  9. :target: https://odoo-community.org/page/development-status
  10. :alt: Beta
  11. .. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
  12. :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
  13. :alt: License: AGPL-3
  14. .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github
  15. :target: https://github.com/OCA/server-tools/tree/12.0/ir_sequence_standard_default
  16. :alt: OCA/server-tools
  17. .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
  18. :target: https://translation.odoo-community.org/projects/server-tools-12-0/server-tools-12-0-ir_sequence_standard_default
  19. :alt: Translate me on Weblate
  20. .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
  21. :target: https://runbot.odoo-community.org/runbot/149/12.0
  22. :alt: Try me on Runbot
  23. |badge1| |badge2| |badge3| |badge4| |badge5|
  24. Set the implementation to "Standard" in all your current Sequences
  25. (ir.sequence) and all new sequences are created as "Standard" by default
  26. instead of "No Gap" implementation.
  27. What's the problem with "No Gap" Sequence Implementations
  28. =========================================================
  29. "No Gap" is the default value of sequences in Odoo. However, this kind of
  30. sequences cause more locks and can turn a database slow.
  31. Taking as example an invoice, if you assign an invoice number to one record,
  32. but it sill not finish the process, this process must end in order to another
  33. invoice could assign a new number and there was no gaps between the invoice
  34. numbers. It seems to be good at first sight. But the problem starts when there
  35. is a chained process.
  36. Imagine that there is one user that executes a process that produces 100
  37. invoices and these at the same time produces 100 journal entries that also use
  38. a consecutive (no gap) sequence. And also those invoices are sent to sign with
  39. and external institution (that could take 2 seconds in giving a response
  40. because of internet latency or server load), and maybe they made another
  41. calculations that makes them to take 5 seconds more for each invoice, and all
  42. this is chained to one single transaction. This means that for 8.5 minutes
  43. anybody else could confirm invoices, neither journal entries of the involved
  44. journals.
  45. Now, think there is 20 users that have to execute a similar process. The
  46. problem turns exponential. If another user comes to make an operation with the
  47. same jornal it will thrown a concurrency failure.
  48. You can mitigate it if you segment each transaction and don't chain them. It
  49. means, making commit for each invoice or process. It reduces the
  50. probability that there is a concurrency error or a lock wait. However, it still
  51. not solve it completely.
  52. Why to use Sequences with "Standard" Implementation
  53. ===================================================
  54. If you use the standard sequence of PosgreSQL, it doesn't lock because at the
  55. moment the request is done, the next sequence number it is changed in an
  56. isolated transaction, and it have not to wait the other transaction to end.
  57. However, if the transaction produces a rollback, this sequence isn't reverted,
  58. it means, it's lost. It may be not not serious because when you cancel or
  59. remove records that number is lost too.
  60. What this module does
  61. =====================
  62. To eliminate completely that concurrency/slowness problem, this module changes
  63. all the sequences (ir.sequence) implementation from "No Gap" to "Standard" with
  64. the awareness that it will skip numbers. In the majority of database models
  65. and many users projects there is no problem with that jump occurs.
  66. **Table of contents**
  67. .. contents::
  68. :local:
  69. Bug Tracker
  70. ===========
  71. Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-tools/issues>`_.
  72. In case of trouble, please check there if your issue has already been reported.
  73. If you spotted it first, help us smashing it by providing a detailed and welcomed
  74. `feedback <https://github.com/OCA/server-tools/issues/new?body=module:%20ir_sequence_standard_default%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
  75. Do not contact contributors directly about support or help with technical issues.
  76. Credits
  77. =======
  78. Authors
  79. ~~~~~~~
  80. * Vauxoo
  81. Contributors
  82. ~~~~~~~~~~~~
  83. - Moises López <moylop260@vauxoo.com>
  84. - Erick Birbe <erick@vauxoo.com>
  85. Maintainers
  86. ~~~~~~~~~~~
  87. This module is maintained by the OCA.
  88. .. image:: https://odoo-community.org/logo.png
  89. :alt: Odoo Community Association
  90. :target: https://odoo-community.org
  91. OCA, or the Odoo Community Association, is a nonprofit organization whose
  92. mission is to support the collaborative development of Odoo features and
  93. promote its widespread use.
  94. .. |maintainer-moylop260| image:: https://github.com/moylop260.png?size=40px
  95. :target: https://github.com/moylop260
  96. :alt: moylop260
  97. .. |maintainer-ebirbe| image:: https://github.com/ebirbe.png?size=40px
  98. :target: https://github.com/ebirbe
  99. :alt: ebirbe
  100. Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:
  101. |maintainer-moylop260| |maintainer-ebirbe|
  102. This module is part of the `OCA/server-tools <https://github.com/OCA/server-tools/tree/12.0/ir_sequence_standard_default>`_ project on GitHub.
  103. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.