Commit graph

379 commits

Author SHA1 Message Date
Nahuel Operto
c0e779998d
fix: lstrip for query writes detection (#26180) 2024-04-30 18:09:22 +05:30
Ankush Menat
dd82ab415c
fix: add missing impl for is_column_missing (#26225)
I removed it assuming it's already implemented in actual classes, but
it's alias for is_missing_column.
2024-04-29 16:46:12 +00:00
Ankush Menat
c1bf152b89
fix: handle interface error during report timeout (#25893) 2024-04-10 06:57:36 +00:00
Akhil Narang
ae34b12ce8
Merge pull request #22548 from blaggacao/feat/uds
feat: support unix domain sockets
2024-03-29 18:11:01 +05:30
Ankush Menat
de48dc2c04
fix: db explain (#25724)
This broke from some recent changes.

It's just a wrapper, so probably no one uses it.
Anyway, fixed and added test to prevent it.
2024-03-29 10:23:12 +00:00
David
39d4318a27
feat: enable db socket connection 2024-03-29 10:29:50 +01:00
Ankush Menat
be579f9a8d
fix: sql_ddl - always ensure commit (#25704) 2024-03-28 13:13:55 +00:00
Ankush Menat
23204c0c05
Merge pull request #25256 from ankush/no_commit_doc_events
fix: disable transaction commits during doc events
2024-03-28 12:28:12 +05:30
Ankush Menat
e5a64fd50c test: transaction control 2024-03-28 11:58:38 +05:30
Ankush Menat
f66b23b96d fix: handle nested event calls
Treat disable_transaction_control as a stack incr/decr when moving in
and out of context.
2024-03-28 11:27:24 +05:30
Ankush Menat
071e269548 fix!: Switch to creation as default sort order 2024-03-27 11:18:28 +05:30
Ankush Menat
13c74ec231 fix: Use debug log to log DB queries 2024-03-10 12:49:19 +05:30
Ankush Menat
638dbb6bcd fix: disable transaction commits during doc events
- Events like doc.save and doc.submit need to be atomic
- Document hooks can make it not so atomic.

This is extending server script behaviour where server script hooks are
not allowed to commit/rollback.
2024-03-06 14:53:00 +05:30
Ankush Menat
e810fb7eca feat: nowait to skip blocking locks 2024-02-29 16:30:24 +05:30
Shankarv19bcr
437beaa735 fix: typo 2024-02-21 17:19:32 +05:30
Akhil Narang
3f1e19de85
refactor(treewide): enable RUF rules
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-02-21 16:20:28 +05:30
Raffael Meyer
68eb2d978d
fix: keep order in get_values_from_single (#24907)
* fix: keep order in `get_values_from_single`

* fix: add test for destructuring

---------

Co-authored-by: Ankush Menat <ankush@frappe.io>
2024-02-19 05:35:35 +00:00
Suraj Shetty
803c02258a fix: Ignore "Invalid Doctype" validation if ignore flag is passed 2024-02-09 14:08:24 +05:30
Akhil Narang
26ae0f3460
fix: ruff fixes
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-02-07 17:04:31 +05:30
Ankush Menat
de9ac89748 style: re-format with ruff 2024-02-05 18:53:33 +05:30
David Arnold
a1a653632f
fix: avoid changing argument order 2024-01-19 10:31:57 +01:00
David Arnold
f889d09d0b
fix: set defaults at the highest level interface 2024-01-17 18:59:34 +01:00
Ankush Menat
484049c5ae
fix: simultenous sessions ux (#24387)
* fix: set 2 as simultaneous_sessions by default

* fix: Correct offset for simultaneous_sessions

* refactor: use freeze_time instead of patching

* chore: misleading docstring

* test: set lower simultaneous_sessions for test
2024-01-16 13:36:05 +00:00
Akhil Narang
fff866417d
fix: format
Got messed up during rebase - forgot to run pre-commit before `git rebase --continue`

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-01-16 12:35:01 +05:30
Akhil Narang
d1906b3c16
refactor: add in a fallback to use db name as db user name
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-01-16 12:35:01 +05:30
Akhil Narang
c721fcf8c4
refactor: allow setting a db user name different from the database name
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-01-16 12:35:01 +05:30
Ankush Menat
a2525e545a
perf: Unbuffered cursors for large result sets (#24365)
If you're reading 1000s of rows from MySQL, the default behaviour is to
read all of them in memory at once.

One of the use case for reading large rows is reporting where a lot of
data is read and then processed in Python. The read row is hoever not
used again but still consumes memory until entire function exits.

SSCursor (Server Side Cursor) allows fetching one row at a time.

Note: This is slower than fetching everything at once AND has risk of
connection loss. So, don't use this as a crutch. If possible rewrite
code so processing is done in SQL.
2024-01-16 11:00:12 +05:30
Ankush Menat
d5b27061ad perf: avoid duplicate copies of result set
When as_list, as_dict is done we hold on to original result set until
next query is performed. This can be HUGE for large queries.
2024-01-15 12:32:07 +05:30
Ankush Menat
588157df74 feat: frappe.db.sql results as iterator
- Also avoid self.last_result that holds on to large result set reference.
2024-01-15 12:32:02 +05:30
David Arnold
3fa76b827c
chore: name current db handle properly 2024-01-14 17:14:21 +01:00
Ankush Menat
e45e313bfb
feat: Skip locked rows while selecting (#24298) 2024-01-13 09:49:27 +05:30
Hussain Nagaria
8d2137c265 docs: consistent doc strings 2023-12-18 18:27:39 +05:30
Akhil Narang
ccc2bdad52
fix: go back to original transaction handling mechanism
This reverts the following:
07acfeed47 chore: move check_implicit_commit() call back to its original location
fc38a0b503 chore: simplify transaction handling
1e29e81543 chore: rework implicit commit checks
ae0a3fd202 feat: allow ignoring implicit commit warning

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-11-16 14:51:57 +05:30
Akhil Narang
6b49b5f32a
chore: move check_implicit_commit() call back to its original location
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-11-16 14:51:57 +05:30
Akhil Narang
806748b063
chore: simplify transaction handling
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-11-16 14:51:57 +05:30
Akhil Narang
f9b9184223
chore: rework implicit commit checks
Add in some more "reset" queries
- begin
- start

Also check *after* resetting

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-11-16 14:51:57 +05:30
Akhil Narang
6550e0769b
feat: allow ignoring implicit commit warning
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-11-16 14:51:57 +05:30
Ankush Menat
0d5f28d569 feat: rename custom field 2023-09-25 12:25:28 +05:30
Ankush Menat
acd1b9d64e
fix: Don't run query if dn is None (#22475) 2023-09-19 15:11:15 +00:00
Ankush Menat
961585f1d9
fix: misc dx improvemnts (#22188)
* fix(dx): simplify adding callbacks

frappe.db.after_commit(func) == frappe.db.after_commit.add(func)

* fix: trace id missing

DB gets initted before request
2023-08-28 07:01:25 +00:00
Ankush Menat
730e906dfd
refactor!: remove implicit primary key from logs (#22209) 2023-08-26 16:01:47 +05:30
Ankush Menat
59e49d89fe feat: include Trace ID in all SQL queries 2023-08-23 13:59:24 +05:30
Ankush Menat
22a3a56d44 chore: remove conflict-marker look-alike
This is annoying when trying to find git conflicts

[skip ci]
2023-07-28 11:45:56 +05:30
Ankush Menat
adf30693a9 ci: update pyupgrade 2023-07-14 14:24:08 +05:30
David Arnold
6b2bb9a2ab
fix: add env overrides for service orchestration (#21577)
This avoids having to manipulate config files in brittle bash
entrypoints that need to react to dynamic service discovery.

This significantly improves the operability of various bench sites.
2023-07-14 11:39:01 +05:30
Ankush Menat
8a37d6d278
perf: reduce memory usage of background processes (#21467)
* perf: defer translation.py imports

This indirectly imports babel which isn't really required most of the
time.

* perf: defer gzip import

* perf: move validate_and_sanitize_search_inputs

This causes all sorts of indirect imports and increases memory usage

* perf: defer requests module imports

* perf: defer system settings import

* perf: defer LOG_DOCTYPES import

Causes many indirect imports

* perf: defer update_site_config

* perf: defer notifications import

* perf: remove unused import

* perf: defer safe exec import

* test: memory usage overhead
2023-06-23 12:51:45 +05:30
Ankush Menat
3f3ee12338 Revert: keep supporting set_value for singles
w/ explicit check for singles

This shouldn't have any performance impact as last function call only
happens if we THINK it's single doctype. use set_single_value to avoid
that extra function call.
2023-06-14 17:30:32 +05:30
Ankush Menat
3005e66e45 refactor!: Drop previously deprecated code 2023-06-13 16:00:43 +05:30
Ankush Menat
fa6dc03cc8
refactor: frappe.cache() usage to frappe.cache (#21282) 2023-06-08 11:47:17 +05:30
Ankush Menat
98b4693dcf perf: finer cache eviction on db.set_value
Instead of nuking everything, just clear matching prefix
2023-06-03 22:53:10 +05:30