1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-05-08 15:01:34 +03:00

27 Commits

Author SHA1 Message Date
Sergei Petrunia
b7fc8e4609 Add ability to compile against MariaDB with new cost model
If MariaDB defines MARIADB_NEW_COST_MODEL, then ha_mcs::scan_time()
has a different signature.
2022-11-10 18:16:44 +03:00
Gagan Goel
973e5024d8 MCOL-4957 Fix performance slowdown for processing TIMESTAMP columns.
Part 1:
 As part of MCOL-3776 to address synchronization issue while accessing
 the fTimeZone member of the Func class, mutex locks were added to the
 accessor and mutator methods. However, this slows down processing
 of TIMESTAMP columns in PrimProc significantly as all threads across
 all concurrently running queries would serialize on the mutex. This
 is because PrimProc only has a single global object for the functor
 class (class derived from Func in utils/funcexp/functor.h) for a given
 function name. To fix this problem:

   (1) We remove the fTimeZone as a member of the Func derived classes
   (hence removing the mutexes) and instead use the fOperationType
   member of the FunctionColumn class to propagate the timezone values
   down to the individual functor processing functions such as
   FunctionColumn::getStrVal(), FunctionColumn::getIntVal(), etc.

   (2) To achieve (1), a timezone member is added to the
   execplan::CalpontSystemCatalog::ColType class.

Part 2:
 Several functors in the Funcexp code call dataconvert::gmtSecToMySQLTime()
 and dataconvert::mySQLTimeToGmtSec() functions for conversion between seconds
 since unix epoch and broken-down representation. These functions in turn call
 the C library function localtime_r() which currently has a known bug of holding
 a global lock via a call to __tz_convert. This significantly reduces performance
 in multi-threaded applications where multiple threads concurrently call
 localtime_r(). More details on the bug:
   https://sourceware.org/bugzilla/show_bug.cgi?id=16145

 This bug in localtime_r() caused processing of the Functors in PrimProc to
 slowdown significantly since a query execution causes Functors code to be
 processed in a multi-threaded manner.

 As a fix, we remove the calls to localtime_r() from gmtSecToMySQLTime()
 and mySQLTimeToGmtSec() by performing the timezone-to-offset conversion
 (done in dataconvert::timeZoneToOffset()) during the execution plan
 creation in the plugin. Note that localtime_r() is only called when the
 time_zone system variable is set to "SYSTEM".

 This fix also required changing the timezone type from a std::string to
 a long across the system.
2022-02-14 14:12:27 -05:00
Leonid Fedorov
04752ec546 clang format apply 2022-01-21 16:43:49 +00:00
Leonid Fedorov
01f3ceb437 replace header guards with #pragma once 2022-01-21 15:24:58 +00:00
Gagan Goel
affb2ae770
MCOL-4769 Fix cache bugs. (#2151)
* MCOL-4769 Do not replay INSERTs and LDIs on the replica nodes when
the write cache is enabled.

* MCOL-4769 If a table is created with the write cache disabled
(i.e. when columnstore_cache_inserts=OFF), make it accessible when
the cache feature is enabled (columnstore_cache_inserts=ON).
2021-11-22 14:20:50 -06:00
Leonid Fedorov
5c5f103f98
MCOL-4839: Fix clang build (#2100)
* Fix clang build

* Extern C returned to plugin_instance

Co-authored-by: Leonid Fedorov <l.fedorov@mail.corp.ru>
2021-08-23 10:45:10 -05:00
Denis Khalikov
c20015a7b2 MCOL-4713 Analyze table implementation. 2021-07-02 12:37:12 +03:00
Alexey Antipovsky
83d3adf466 Fix method declarations to match the base class (-Woverloaded-virtual) 2020-11-17 15:03:10 +03:00
Gagan Goel
50a4fd9f39 MCOL-4285 For Insert...Select, pass the is_cache_insert=true
flag to ha_mcs_impl_start_bulk_insert.

An earlier commit to fix LDI under replication changed the call in
ha_mcs_cache::start_bulk_insert for a non-insert command from
parent::start_bulk_insert_from_cache to parent::start_bulk_insert.
This commit reverts that change for INSERT...SELECT operation.
2020-10-15 13:30:36 -04:00
Gagan Goel
0ee64db3e5 Disable cache_handler for system catalog tables. 2020-10-01 17:00:18 -04:00
Gagan Goel
a1ea633a19 MCOL-4282 Follow up version 2.
Mutate the optimizer flags for prepared statements in:
  1. ha_mcs::open
  2. ha_mcs::discover_check_version

This is done to ensure the optimizer flags are disabled before
JOIN::prepare() is called during "PREPARE stmt FROM ...".
2020-09-25 13:49:52 -04:00
Alexander Barkov
7f6ad16728 MCOL-4303 UPDATE..SET using another table is not updating
The change for MCOL-4264 erroneously added the "lock_type" member
to cal_connection_info, which is shared between multiple tables.
So some tables that were opened for write erroneously identified
themselves as read only.

Moving the member to ha_mcs instead.
2020-09-11 12:26:26 +04:00
Gagan Goel
709290cc3d Port of commit: 1ff23d0cd70d576a0f4e512ce332cff348591d36
from server/columnstore_cache.

Commit message:

Fixed bug in free locks that caused rows in cache to not be properly flushed

Fixed by doing adding external_lock(F_UNLCK) in free_locks.
I also moved unlock of cache_handler to be after changing lock type of
cached tables to ensure that no one can use cached table while this is
happening (as cache table is locked with write lock).
I also fixed a wrong mutex order bug in ha_cache::flush_insert_cache()

Other things:
- Addded share::cached_rows to track inserted rows. This is only used
  for asserts to check the number of rows in the cache.
- Fixed wrong mysql_file_chsize() in case of repair
2020-08-18 18:01:40 -04:00
Gagan Goel
86fb66365c 1. Set 1M as the threshold on the number of records to flush the cache.
2. Set 100k as the batch size when flushing records into ColumnStore, i.e.,
a flush of 1M records will be performed in 10 batches, each being 100k.

3. For INSERT ... SELECT on the cache, use the default insertion method of cpimport.
2020-08-18 18:01:40 -04:00
Gagan Goel
f5a8d228a0 Port of commit ba731bdc6a80e88d32e7440044b548c3e3edc591
from server/columnstore_cache

Commit message:

Fixed crashed bug on simple insert

Other things:
- Added test from columnstore team
- Fixed two reported bugs from columnstore team
- Call free_locks as part of start_trans() instead of get_status()
  to ensure that we have locks both for cached table and cache table
  before we try to free any.
- Store pointers to lock->get_status and lock->update_status for the
  cached table. Was needed by ha_tina in flush_insert_cache to make
  new insert rows visible for the SELECT that caused the flush
2020-08-18 18:01:40 -04:00
Gagan Goel
cb2ddad308 Port of commit 0463e1f722d4d32526760c923e0092a380a9e634
from server/columnstore_cache.

Commit message:

Fixed bug in cache:

- The THR_LOCK org_lock must be stored in a shared structure so that all
  instances of a table can use it. Fixed by adding a ha_cache_share object
  that keeps track of this one.
- Fixed wrong test in get_status_and_flush_cache to detect in insert command
- Fixed in get_status_and_flush_cache that we always free the insert lock
  if we don't need it.
2020-08-18 18:01:40 -04:00
Roman Nozdrin
6b3c6e33c5 MCOL-4152 Reset cond_stack with ha_mcs::reset() call 2020-07-13 13:18:57 +00:00
Gagan Goel
c30d105c30 Use batch inserts for the cache flush. 2020-06-03 15:20:03 -04:00
Gagan Goel
e671b1d1e2 1. Some fixes to the cache interface code.
2. Set a Columnstore_cache table as a non-foreign engine table in isMCSTable().
2020-06-03 15:20:03 -04:00
Gagan Goel
43d5d511d7 Initial port of Monty's code of the ColumnStore cache. 2020-06-03 15:20:03 -04:00
Gagan Goel
01ff2652a6 MCOL-4023 Pushdown WHERE conditions for UPDATE/DELETE.
For certain queries, such as:
  update cs1 set i = 41 where i = 42 or (i is null and 42 is null);
the SELECT_LEX.where does not contain the required where conditions.
Server sends the where conditions in the call to cond_push(), so
we are storing them in a handler data member, condStack, and later
push them down to getSelectPlan() for UPDATES/DELETEs.
2020-06-01 11:03:42 -04:00
Andrew Hutchings
9e588039d5 Merge pull request #1010 from tntnatbry/MCOL-3680
MCOL-3680 mysqld will abort if Columnstore.xml is missing.
Conflicts:
	dbcon/mysql/ha_mcs.cpp
2020-02-28 13:58:00 -05:00
Roman Nozdrin
19b4702a24 This patch fllows the change introduced in the direct_update/delete API
in 10.4.11 to fix MDEV-18973 in Spider.
2019-12-11 08:05:49 -06:00
Andrew Hutchings
3f5e1fd0c8
Merge pull request #964 from mariadb-corporation/MCOL-3529
MCOL-3529 This patch implements direct_update and direct_delete features
2019-12-09 09:40:33 +00:00
Roman Nozdrin
5cedeb110b MCOL-3529 This patch implements direct_update and direct_delete features
to properly report the number of rows affected by UPDATE|DELETE.
2019-11-27 09:33:21 -06:00
Roman Nozdrin
3fabf01e93 MCOL-3593 Disabled full optimizer run and enabled copy-pasted simplify_joins.
Disabled 4th if block in buildOuterJoin to handle non-optimized MDB query
    structures.

    Broke getSelectPlan into pieces: processFrom, processWhere.

MCOL-3593 UNION processing depends on two flags isUnion that comes as
arg of getSelectPlan and unionSel that is a local variable in
getSelectPlan. Modularization of getSelectPlan broke the mechanizm.
This patch is supposed to partially fix it.

MCOL-3593 Removed unused if condition from buildOuterJoin that allows
unsupported construct subquery in ON expression.
Fixed an improper if condition that ignors tableMap entries w/o condition
in external_lock thus external_lock doesn't clean up when the query
finishes.
Fixed wrong logging for queries processed in tableMode. Now rnd_init
properly sends queryText down to ExeMgr to be logged.

MCOL-3593 Unused attribute FromSubQuery::fFromSub was removed.
 getSelectPlan has been modularized into: setExecutionParams,
 processFrom, processWhere. SELECT, HAVING, GROUP BY, ORDER BY
 still lives in getSelectPlan.
Copied optimization function simplify_joins_ into our pushdown
 code to provide the plugin code with some rewrites from MDB it
 expects.
The columnstore_processing_handlers_fallback session variable
 has been removed thus CS can't fallback from SH to partial
 execution paths, e.g. DH, GBH or plugin API.

MCOL-3602 Moved MDB optimizer rewrites into a separate file.

Add SELECT_LEX::optimize_unflattened_subqueries() call to fix IN
 into EXISTS rewrite for semi-JOINs with subqueries.

disable_indices_for_CEJ() add index related hints to disable
 index access methods in Cross Engine Joins.

create_SH() now flattens JOIN that has both physical tables and
 views. This fixes most of views related tests in the regression.
2019-11-25 10:03:32 -06:00
Gagan Goel
c8df46ed26 Replace ha_calpont with ha_mcs in the source code and filenames in the plugin code. 2019-10-11 17:33:43 +00:00