[MXS-1474] Cache module should be ACID compliant Created: 2017-10-16  Updated: 2017-12-01  Resolved: 2017-10-31

Status: Closed
Project: MariaDB MaxScale
Component/s: cache
Affects Version/s: None
Fix Version/s: 2.2.1

Type: New Feature Priority: Blocker
Reporter: Michaël de groot Assignee: Johan Wikman
Resolution: Done Votes: 0
Labels: None

Sprint: 2017-44

 Description   

Hi,

From our lunch talk I got the impression that the cache module is not ACID compliant:
SELECT statements inside a read/write transactions return cached results. This means the statement is not sent to the server which means the read locks are not set. With REPEATABLE-READ (or SERIALIZABLE) isolation level this makes it not ACID compliant.

Please change this so read/write transactional reads do not return cached results.

Thanks,
Michaël



 Comments   
Comment by Johan Wikman [ 2017-10-16 ]

I'm thinking of adding the following kind of configuration parameter.


isolation
An enumeration option specifying how the cache should behave when transactions that are not explicitly read-only are used:

  • read_committed: The cache will return cached data until the first statement that modifies the database. Thereafter all statements are forwarded to the backend.
  • repeatable_read: The cache will never return cached data, but all statements are always forwarded to the backend.

isolation=repeatable_read

Default is read_committed.


How does that sound?

Comment by Johan Wikman [ 2017-10-23 ]

This issue is in fact not limited to read/write transactions, but applies to read-only as well.

Suppose a transaction is started and something is selected and suppose the result was found from the cache. Then suppose the same thing is selected again, but this time the ttl has been reached and the data is fetched from the server. There is no guarantee that the result will be identical. Thus, if read_committed behaviour is required, then caching cannot be used during transactions.

So, I think I will still introduce that isolation configuration parameter and if its value is set to repeatable_read then no data will be returned from the cache during transactions. It will be populated though, so selects done with autocommit being enabled will be served from the cache.

Comment by Johan Wikman [ 2017-10-31 ]

There is now a new configuration parameter cache_in_transactions that can take the following values:

  • never: During transactions, nothing is ever returned from the cache. The cache is populated in explicitly read-only transactions. In not explcitly read-only transactions the cache is populated until the first non-SELECT statement.
  • read_only_transactions: During explicitly read-only transactions, the cache is used and populated. In not explicitly read-only transactions the cache is populated until the first non-SELECT statement.
  • all_transactions: During explicitly read-only transactions, the cache is used and populated. In not explicitly read-only transactions the cache is used and populated until the first non-SELECT statement.

With read_only_transactions, explicitly read only transactions behave as if the isolation level of the server were read committed. With all_transactions all transactions behave as if the isolation level of the server were read committed.

Generated at Thu Feb 08 04:07:01 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.