[ 
https://issues.apache.org/jira/browse/CASSANDRA-15996?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17213740#comment-17213740
 ] 

Berenguer Blasi commented on CASSANDRA-15996:
---------------------------------------------

I have been focusing on this one today and I want to share my findings. Here is 
the stdout from David's test for the record:

{noformat}
AssertionError: Log message should be print for CAP and CAP_NOWARN policy 
assert []
self = <ttl_test.TestTTL object at 0x7f3cf857ccf8>

    @since('2.1')
    def test_expiration_overflow_policy_cap(self):
>       self._base_expiration_overflow_policy_test(default_ttl=False, 
> policy='CAP')

ttl_test.py:343: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <ttl_test.TestTTL object at 0x7f3cf857ccf8>, default_ttl = False
policy = 'CAP'

    def _base_expiration_overflow_policy_test(self, default_ttl, policy):
        """
            Checks that expiration date overflow policy is correctly applied
            @jira_ticket CASSANDRA-14092
            """
        MAX_TTL = 20 * 365 * 24 * 60 * 60  # 20 years in seconds
        default_time_to_live = MAX_TTL if default_ttl else None
        self.prepare(default_time_to_live=default_time_to_live)
    
        # Restart node with expiration_date_overflow_policy
        self.cluster.stop()
        
self.cluster.start(jvm_args=['-Dcassandra.expiration_date_overflow_policy={}'.format(policy)])
        self.session1 = self.patient_cql_connection(self.cluster.nodelist()[0])
        self.session1.execute("USE ks;")
    
        # Try to insert data, should only fail if policy is REJECT
        query = 'INSERT INTO ttl_table (key, col1) VALUES (%d, %d)' % (1, 1)
        if not default_time_to_live:
            query = query + "USING TTL %d" % (MAX_TTL)
        try:
            result = self.session1.execute_async(query + ";")
            result.result()
            if policy == 'REJECT':
                self.fail("should throw InvalidRequest")
            if self.cluster.version() >= '3.0':  # client warn only on 3.0+
                if policy == 'CAP':
                    logger.debug("Warning is {}", result.warnings[0])
                    assert 'exceeds maximum supported expiration' in 
result.warnings[0], 'Warning not found'
                else:
                    assert not result.warnings, "There should be no warnings"
    
        except InvalidRequest as e:
            if policy != 'REJECT':
                self.fail("should not throw InvalidRequest")
    
        self.cluster.flush()
        # Data should be present unless policy is reject
        assert_row_count(self.session1, 'ttl_table', 0 if policy == 'REJECT' 
else 1)
    
        # Check that warning is always logged, unless policy is REJECT
        if policy != 'REJECT':
            node1 = self.cluster.nodelist()[0]
            prefix = 'default ' if default_ttl else ''
            warning = node1.grep_log("Request on table {}.{} with {}ttl of {} 
seconds exceeds maximum supported expiration"
                                     .format('ks', 'ttl_table', prefix, 
MAX_TTL))
>           assert warning, 'Log message should be print for CAP and CAP_NOWARN 
> policy'
E           AssertionError: Log message should be print for CAP and CAP_NOWARN 
policy
E           assert []

ttl_test.py:410: AssertionError
{noformat}

As we can see from the code above we're being called with policy 'CAP'. And 
following the test code we make it through to line 392 where we 
[check|https://github.com/apache/cassandra-dtest/blob/master/ttl_test.py#L392] 
there was a client warning indeed. So the TTL 'business logic' is happening and 
it's correct. The only bit missing is that being logged which falls on 
{{NoSpamLogger}}'s shoulders. I can only think of some edge case on 
{{NoSpamLogger}} missing to log, which would explain why it happens so seldom, 
why it hasn't been repro'ed so far and why I didn't manage to repro either even 
on a thinned down machine.

> Fix flaky python dtest test_expiration_overflow_policy_capnowarn - 
> ttl_test.TestTTL
> -----------------------------------------------------------------------------------
>
>                 Key: CASSANDRA-15996
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-15996
>             Project: Cassandra
>          Issue Type: Bug
>          Components: Test/dtest/python
>            Reporter: David Capwell
>            Assignee: Adam Holmberg
>            Priority: Normal
>             Fix For: 3.11.x, 4.0-beta
>
>
> https://app.circleci.com/pipelines/github/dcapwell/cassandra/361/workflows/3a42fa45-1f60-4c95-86a4-15a6773e384e/jobs/1860
> {code}
> >           assert warning, 'Log message should be print for CAP and 
> > CAP_NOWARN policy'
> E           AssertionError: Log message should be print for CAP and 
> CAP_NOWARN policy
> E           assert []
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to