Details

      Description

      A problem has been highlighted where variables have been unbound where they should have been bound.

      This may be traced to an implementation problem with ConcurrentWeakValueHashMap putIfAbsent method.

      This issue was finally identified when two distinct instances of Var were obtained from Var.var(String) for the same variable name leading to an unconstrained cross product join since the variable in the query did not match the variable in the binding set. This probably arose when an old weak reference for a variable was clear simultaneous with the creation by two threads of distinct Var instances for the same variable name that was recently cleared from the CWVHM.

      Note: This may also be responsible for a condition reported by one customer where a variable would sometimes not have a binding in a SPARQL result.

      Note: We have not been able to create a test that reliably demonstrates the underlying failure. However, failures have occasionally been observed by repeated runs of TestVar.

        Activity

        Hide
        bryanthompson bryanthompson added a comment -

        This problem has been resolved by recursion through putIfAbsent() if the thread loses the data race as illustrated in the following snip from putIfAbsent:

                        if (map.replace(k, oldRef, ref)) {
        
                            if (queue != null) {
        
                                // no reference under that key.
                                synchronized (queue) {
        
                                    // put the new value onto the hard reference queue.
                                    if (queue.add(v) && DEBUG) {
        
                                        log.debug("put: key=" + k + ", val=" + v);
        
                                    }
        
                                }
        
                            }
                            
                            // notification.
                            didUpdate(k, ref, oldRef);
        
                            // the old value for the key was a cleared reference.
                            return null;
        
                        } else {
                            
                            /**
                             * We lost a potential concurrent data race, so make
                             * recursive call to ensure correct value is returned.
                             * 
                             * @see <a href="http://trac.bigdata.com/ticket/1004">
                             *      Concurrent binding problem </a>
                             */
        
                            return putIfAbsent(k, v);
                            
                        }
        

        Committed revision 8631 (initial fix)
        Committed revision 8633 (code cleanup on that initial fix)

        Show
        bryanthompson bryanthompson added a comment - This problem has been resolved by recursion through putIfAbsent() if the thread loses the data race as illustrated in the following snip from putIfAbsent: if (map.replace(k, oldRef, ref)) { if (queue != null) { // no reference under that key. synchronized (queue) { // put the new value onto the hard reference queue. if (queue.add(v) && DEBUG) { log.debug("put: key=" + k + ", val=" + v); } } } // notification. didUpdate(k, ref, oldRef); // the old value for the key was a cleared reference. return null; } else { /** * We lost a potential concurrent data race, so make * recursive call to ensure correct value is returned. * * @see <a href="http://trac.bigdata.com/ticket/1004"> * Concurrent binding problem </a> */ return putIfAbsent(k, v); } Committed revision 8631 (initial fix) Committed revision 8633 (code cleanup on that initial fix)

          People

          • Assignee:
            martyncutcher martyncutcher
            Reporter:
            martyncutcher martyncutcher
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: